SSL证书常用的OPENSSL命令

技术社区 作者:iTrustSSL 2025-06-05 04:07:28 阅读:70

1. 生成CSR命令

以下命令用来生成CSR、Key,以及生成自签发证书

生成CSR - RSA加密算法

openssl req -out itrustssl.cn.csr -new -sha256 -newkey rsa:2048 -nodes -keyout itrustssl.cn.key

生成CSR - ECC加密算法

openssl ecparam -out server.key -name prime256v1 -genkey
openssl req -new -key server.key -out server.csr

生成自签发证书命令

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt

从密钥生成CSR

openssl req -out CSR.csr -key privateKey.key -new

从证书文件生成CSR

openssl x509 -x509toreq -in certificate.crt -out CSR.csr -signkey privateKey.key

去除Key密码

openssl rsa -in privateKey.pem -out newPrivateKey.pem

2. OPENSSL相关校验CSR KEY 证书命令

以下命令用来检查、校验Key CSR 以及证书

检查校验CSR包含信息命令

openssl req -text -noout -verify -in CSR.csr

检查校验KEY包含信息命令

openssl rsa -in privateKey.key -check

检查校验SSL证书命令

openssl x509 -in certificate.crt -text -noout

检查校验PKCS#12(后缀为.pfx 或 .p12)格式证书命令

openssl pkcs12 -info -in keyStore.p12


3. OPENSSL的相关排查验证命令

以下命令用来检查、校验Key CSR 以及证书

检查证书、CSR、Key是否匹配命令

openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl req -noout -modulus -in CSR.csr | openssl md5

检查已安装SSL证书网站的证书信息命令

openssl s_client -connect www.baidu.com:443


4. PEM转换使用的OPENSSL命令

转换 PEM 到 DER

openssl x509 -outform der -in certificate.pem -out certificate.der

转换 PEM 到 P7B

openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer

转换 PEM 到 PFX

openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

转换 PEM 到 JKS

点击查看 PEM转tomcat使用的jks命令


5. DER转换使用的OPENSSL命令

转换 DER 到 PEM

openssl x509 -inform der -in certificate.cer -out certificate.pem


6. P7B转换使用的OPENSSL命令

转换 P7B 到 PEM

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

转换 P7B 到 PFX

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
openssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer


7. PFX转换使用的OPENSSL命令

转换 PFX 到 PEM

openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes

延伸阅读
  • iTrustSSL证书夏季大促,最高直降92.5%!

    上云购SSL证书,首选iTrustSSL!2025年7月30日-2025年8月10日,iTrustSSL限时优惠,爆款iTrustSSL DV单域名证书首购50元/张起!除上述活动外,另享“新老同享”

  • 最低50元/年 iTrustSSL打破行业底价的SSL证书新选择

    当前网络安全形势日益严峻,全球网站HTTPS加密覆盖率已超过90%。传统SSL证书动辄上千元的年费让中小企业望而却步,而免费证书又存在兼容性差、有效期短等痛点。iTrustSSL通过技术创新和规模化运

  • SSL证书吊销与重新签发操作规范

    当网站的域名发生变化时,原有的SSL证书将不再适用。在这种情况下,需要吊销旧的SSL证书并重新签发新的证书以覆盖新的域名。本文将详细介绍域名变更时SSL证书吊销与重新签发的操作规范。一、域名变更的原因

赞助链接
在线咨询

Copyright © 2015 KnowSafe All rights reserved.

蜀ICP备20006130号-8