SSL证书常用的OPENSSL命令

信息安全 作者:云头条 2025-06-05 04:07:29 阅读:14

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

延伸阅读
  • 宝塔面板SSL证书安装指南

    在宝塔面板上安装SSL证书是一个相对简单的过程,主要步骤包括准备SSL证书、登录宝塔面板、上传证书文件、配置SSL设置。以下是详细的步骤指南:一、准备工作1.购买SSL证书从正规的证书颁发机构(CA)

  • cPanel面板SSL证书安装指南

    在cPanel面板中安装SSL证书是一个相对直接的过程。以下是一个详细的步骤指南,帮助你完成SSL证书的安装:第一步:登录到cPanel帐户1.打开你的网页浏览器并输入你的cPanel登录地址,通常是

  • SSL证书过期时会发生什么

    SSL证书主要通过加密数据传输,确保用户与网站之间的信息安全。这种加密技术能够有效防止数据在传输过程中被截获和篡改,尤其是涉及敏感信息时,SSL证书显得尤为重要。SSL证书的有效期通常免费的是90天,

赞助链接

Copyright © 2024 5xcloud.com All rights reserved.

蜀ICP备20006130号