Save OpenSSL Command Output to File


How to save the output of an OpenSSL command into a file? I want to make a copy of the server certificate display in the "s_client -connect" command output.



If want to save the output an OpenSSL command into a file, you need to run the entire OpenSSL command at the Windows command prompt with the Windows output redirect ">" option as shown below:

C:\Users\fyicenter>\local\openssl\openssl.exe s_client \
   -connect > twitter.pem

depth=1 C = US, O = DigiCert Inc, OU =, CN = DigiCert 
   SHA2 Extended Validation Server CA
verify error:num=20:unable to get local issuer certificate


C:\Users\fyicenter>type twitter.pem

Certificate chain
 0 s:/businessCategory=Private Organization/jurisdictionC=US/jurisdictionST=Delaware
   /serialNumber=4337446/street=Suite 900/street=1355 Market St/postalCode=94103
   /C=US/ST=California/L=San Francisco/O=Twitter, Inc./OU=Twitter Security/
   i:/C=US/O=DigiCert Inc/ SHA2 Extended Validation Server CA
 1 s:/C=US/O=DigiCert Inc/ SHA2 Extended Validation Server CA
   i:/C=US/O=DigiCert Inc/ High Assurance EV Root CA
Server certificate

What we did in this tutorial is:

  • The "openssl s_client" command was executed on the Windows command line prompt directly.
  • The "> twitter.pem" Windows output redirection was used to save the output to the "twitter.pem" file.
  • File name "twitter.pem" was used because the output contains the server certificate.


OpenSSL "s_client" Command

⇒⇒OpenSSL Tutorials

2012-07-24, 12257👍, 0💬