自签文档签名证书

本文档详细介绍了如何自签文档签名证书,包括生成根证书及自签名证书、使用根证书颁发证书,以及查看证书信息的步骤。关键操作涉及openssl命令行工具,如genrsa、req、x509等,用于创建和管理证书。请注意,自签证书不在可信根证书列表中,需手动将其添加为可信。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自签文档签名证书

因为文档签名证书的密钥用法有:nonRepudiation, digitalSignature

所以可以在openssl.cnf文件中设置keyUsage = nonRepudiation, digitalSignature, keyEncipherment

1.生成根证书及自签名证书
  • 1.创建根证书私钥

    openssl genrsa -out root.key 1024

  • 2.创建根证书请求文件

    openssl req -new -out root-req.csr -key root.key -keyform PEM

  • 3.自签根证书

    openssl x509 -req   -extfile openssl.cnf -extensions v3_req  -in root-req.csr -out root-cert.cer -signkey root-key.key -CAcreateserial -days 3650

    重要说明: -extfile openssl.cnf -extensions v3_req  参数是生成 X509 V3 版本的证书的必要条件。 openssl.cnf  是系统自带的OpenSSL配置文件,该配置文件默认开启 X509 V3 格式。下同。

  • 4.导出P12格式证书

    openssl pkcs12 -export -clcerts -in root-cert.cer -inkey root-key.key -out root.p12

2.使用根证书颁发证书
  • 1.生成证书Key

    openssl genrsa -out client-key.key 1024

  • 2.生成证书请求文件

    openssl req -new -out client-req.csr -key client-key.key

  • 3.生成证书,并使用根证书签名

    openssl x509 -req -extfile /etc/pki/tls/openssl.cnf -extensions v3_req -in client-req.csr -out client-cert.cer -signkey client-key.key -CA root-cert.cer  -CAkey root-key.key -CAcreateserial -days 3650

  • 4.生成客户端P12格式的证书

    openssl pkcs12 -export -clcerts -in client-cert.cer -inkey client-key.key -out client.p12

3.查看证书信息

openssl x509  -in client-cert.cer -text -noout

**注意:**因为是自签证书,所以不在计算机的可信根证书列表中,所以需要我们将根证书添加到可信根证书中。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值