openssl 常用命令

私钥格式转换
# openssl rsa -in ca.key.pem -inform PEM -out ca.key.der -outform  DER

证书格式转换(pem --> der)
# openssl x509 -in ca.cer -inform PEM -out ca.der -outform DER

证书格式转换(pem  -->  p12)
# openssl pkcs12 -export -out test.p12 -inkey private.key -in certificate.pem

查看证书或ca
# openssl x509 -noout -text -in server.cer

CA与签发的证书的验证(root-ca.crt 签发 sub-ca.crt, sub-ca.crt签发server.crt,combine.crt是root-ca.crtsub-ca.crt的合成):
# cat sub-ca.crt root-ca.crt > combine.crt
# openssl verify -verbose -CAfile combine.crt server.crt


利用openssl单向认证过程:
# openssl s_server -accept 809 -debug -msg -bugs  -www -CAfile ca.cer -cert server.cer -key server.key 


利用openssl双向认证过程:
# openssl s_server -port 8002 -cert server.cer -key server.key -CAfile ca.cer -debug 
# openssl s_client -host 127.0.0.1 -port 8002 -cert client.cer -key client.key -CAfile ca.cer -debug  

你可能感兴趣的:(LINUX)