Ssl – Unable to get certificate expiry date

opensslsslssl-certificate

Unable to get certificate expiry date using below command.

Command:
    openssl s_client -servername www-abcecommerce.com -connect www-abcecommerce.com:443 2>/dev/null | openssl x509 -noout -issuer -subject -dates

Error:    
    unable to load certificate
    18936:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

Best Answer

openssl s_client -servername www-abcecommerce.com -connect www-abcecommerce.com:443 2>/dev/null ...

There is no need to pipe stderr to /dev/null since it would not be put into the pipe anyway. And once you skip dropping stderr you'll see:

gethostbyname failure
connect:errno=0

Thus, the domain name you've used is simply wrong. Therefore the connection fails and therefore it cannot do a TLS handshake and therefore it cannot provide the certificate and therefore you cannot extract information from the certificate.

It might be that the real web site you've wanted to analyze is www.abcecommerce.com and not www-abcecommerce.com. Only, this site is only accessible by HTTP and not by HTTPS which means no certificate either.