Use openssl to Extract Site Certificate

You can use the openssl command to extract the SSL certificate from a secure site with the following command:

openssl s_client -connect www.xephixus.com:443 2>/dev/null </dev/null |  sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'

The resulting output will be like the following which is the site SSL certificate:

-----BEGIN CERTIFICATE-----
MIIC/zCCAeegAwIBAgIScSWjL6dQ58b6iWQALrKmL5oUMA0GCSqGSIb3DQEBCwUA
MIGbMQ4wDAYDVQQIEwVUZXhhczEQMA4GA1UEBxMHSG91c3RvbjEbMBkGA1UEChMS
UXVhbnRsYWIgRmluYW5jaWFsMQswCQYDVQQLEwJJVDEiMCAGA1UEAxMZZGFsLXdl
YnB4eTAxLnF1YW50bGFiLmNvbTEpMCcGCSqGSIb3DQEJARYaZGwtaXRzZWN1cml0
eUBxdWFudGxhYi5jb20wHhcNMjMwMjE3MTYyMDM5WhcNMjMwNTE4MTYyMDM4WjAX
MRUwEwYDVQQDEwx4ZXBoaXh1cy5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC
AAS5q0a4zbh50lUzryzEDzULWqF6nePNwJiSQl0UvEYyrm1WWigQaS1xv6EeysAP
kmTL7T1WxUh8v3ELvuq+ga5Ko4GKMIGHMA4GA1UdDwEB/wQEAwIHgDAdBgNVHSUE
FjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQU
wGHIoEyP1SpG1bx6EG/tnRHweK4wKQYDVR0RBCIwIIIQd3d3LnhlcGhpeHVzLmNv
bYIMeGVwaGl4dXMuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQC4pbtX5hOA1EPVq5Rm
r6alnkXVKiLg1xqfG/X9kfFhcluIMtgZpP+VtlO/QjEKQDRMPj/+Yuz/dT9lp8od
iRpKU1IKc747ApVcrn4ymgqTwGGIeh96tNbHi2HfdKJ59DDpN21oquWmhkLQ4Udm
zbVI5lswQrN0vUq+zXCnDntiJ+ExWto5flXlkFNi9ffvqLF4W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