5

I can see the certificate with this command

openssl s_client -host {HOST} -port 443 -prexit -showcerts

How can I save the x509 cert of the website in a PEM - File?

user3653164
  • 153
  • 1
  • 1
  • 3

1 Answers1

7

try

echo "" | openssl s_client -host {HOST} -port 443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'  > cert.pem

then to get all certs in chain , a quick way could be

echo "" | openssl s_client -host {HOST} -port 443 -showcerts | awk '/BEGIN CERT/ {p=1} ; p==1; /END CERT/ {p=0}' > allcerts.pem
gnafou
  • 151
  • 3