Reputation: 12518
As the title says. I need to use it to work around an SSL error I am getting in my application.
Upvotes: 1
Views: 5080
Reputation: 2836
You can do this with openssl via terminal, this question has actually been asked over on ServerFault.
In order to download the certificate, you need to use the client built into openssl like so:
echo -n | openssl s_client -connect HOST:PORTNUMBER | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/$SERVERNAME.cert
That will save the certificate to /tmp/$SERVERNAME.cert.
You can use -showcerts if you want to download all the certificates in the chain. But if you just want to download the server certificate, there is no need to specify -showcerts
echo -n gives a response to the server, so that the connection is released
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' removes information about the certificate chain. This is the preferred format to import the certificate into other keystores.
Upvotes: 2