How to obtain the certificates for a remote server

Knowledge Base - How To

How to obtain the certificates for a remote server

To read the certificates as an output for a site like “server.com” reachable on port 123, run

 

$ openssl s_client -showcerts -connect server.com:123 </dev/null 2>/dev/null

 

There could be more than one certificates that will show up like

 

-----BEGIN CERTIFICATE-----
MIIFYjCCBEqgAwIBAgIQd70NbNs2+RrqIQ/E8FjTDTANBgkqhkiG9w0BAQsFADBX
.

.
d0lIKO2d1xozclOzgjXPYovJJIultzkMu34qQb9Sz/yilrbCgj8=
-----END CERTIFICATE-----
 

 

i.e.

 

$ openssl s_client -showcerts -connect google.com:443 </dev/null 2>/dev/null