检测nginx PEM格式证书与私钥是否匹配
XXX.crt 为证书
XXX.key 为私钥
```
openssl x509 -noout -modulus -in XXX.crt | openssl md5
openssl rsa -noout -modulus -in XXX.key | openssl md5
```
```
(openssl x509 -noout -modulus -in XXX.crt | openssl md5; openssl rsa -noout -modulus -in XXX.key | openssl md5) | uniq
```
```
openssl pkey -in XXX.key -pubout -outform pem | sha256sum
openssl x509 -in XXX.crt -pubkey -noout -outform pem | sha256sum
```
查看证书详情
```
echo | openssl s_client -showcerts -connect www.example.com:443 2> /dev/null | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' > XXX.crt
```
```
openssl x509 -noout -text -in XXX.crt
```
网友评论