1

Is there any way to use wget directly or tweak the source code or use it with openssl in order to obtain the public key from a certificate and save it to a file?

alexandros
  • 77
  • 8
  • If you just want to use the tool, it's probably more for SuperUser. Do you want to do it programmatically? – Bruno Aug 16 '13 at 13:08
  • Yes indeed..The concept is that i have a list of hosts(around 1 million) and i want to get the public key of this hosts and store it to a file – alexandros Aug 16 '13 at 13:34

1 Answers1

1

Not with wget, but with OpenSSL, you can use the same method as in this question for LDAP (except on port 443, if you're interested in HTTPS, presumably).

You can also pipe the output into the openssl x509 -pubkey to get the public key itself.

Something like this should do:

echo -n | openssl s_client -connect www.google.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -pubkey -noout
Community
  • 1
  • 1
Bruno
  • 119,590
  • 31
  • 270
  • 376