1、域名获取
openssl s_client -servername 域名 -connect 域名:443 | openssl x509 -noout -dates
echo | openssl s_client -servername 域名 -connect 域名:443 2>/dev/null | openssl x509 -noout -dates
显示:
notBefore=Apr 14 06:18:55 2023 GMT
notAfter=Apr 13 06:18:54 2024 GMT
2.curl
curl -v "https//域名"
显示:
* start date: 4月 14 06:18:55 2023 GMT
* expire date: 4月 13 06:18:54 2024 GMT
3、通过证书获取
如果你有一个具体的证书文件(例如 .pem、.crt、.cer 等),可以使用 OpenSSL 工具来查看证书信息。
openssl x509 -in xxxx.pem(证书文件名,不是key) -noout -text
显示:
Not Before: Jun 25 01:15:26 2023 GMT
Not After : Jun 24 01:15:25 2024 GMT
# 只查看有效期
openssl x509 -in apiclient_cert.pem -noout -dates
从apiclient_cert.p12中导出密钥部分的文件,为pem格式
部分开发语言和环境,不能直接使用p12文件,而需要使用pem,所以为了方便您使用,已为您直接提供
您也可以使用openssl命令来自己导出:openssl pkcs12 -nocerts -in apiclient_cert.p12 -out apiclient_key.pem