我制作了一个由本地计算机上创建的 CA 签名的 openssl 证书。
该证书已被删除,我不再拥有它。
无法创建具有相同 commonName 的另一个证书,因为 openssl 不允许这样做并且会生成错误:
failed to update database
TXT_DB error number 2
如何撤销证书以创建另一个具有相同 commonName 的证书?
我制作了一个由本地计算机上创建的 CA 签名的 openssl 证书。
该证书已被删除,我不再拥有它。
无法创建具有相同 commonName 的另一个证书,因为 openssl 不允许这样做并且会生成错误:
failed to update database
TXT_DB error number 2
如何撤销证书以创建另一个具有相同 commonName 的证书?
(基于Nilesh 的回答)在默认配置中,openssl 将保留所有已签名证书的副本,/etc/ssl/newcerts
并以其索引号命名。所以grep/etc/ssl/index.txt
获取要撤销的key的序列号,比如1013,然后执行如下命令:
openssl ca -revoke /etc/ssl/newcerts/1013.pem #replacing the serial number
仅当偏离您的设置时,才需要 Nilesh 的答案中提到的-keyfile
和。-cert
openssl.cnf
或者,您也可以更改/etc/ssl/index.txt.attr
以包含该行
unique_subject = no
允许具有相同公用名的多个证书。如果您已经发布了原始证书,那么撤销旧证书是更可取的解决方案,即使您不运行 OSCP 服务器或提供 CRL。
我还没有尝试过,但看起来你需要这样的东西。
openssl ca -revoke bad_crt_file -keyfile ca_key -cert ca_crt
openssl 会自动将您的证书副本保存在 newcerts 目录中。您可能需要检查它以检索您的证书。不幸的是,您需要出示证书才能撤销它。有关详细信息,请参阅以下内容:http: //www.mad-hacking.net/documentation/linux/security/ssl-tls/revoking-certificate.xml
就像其他答案所说,openssl CA 通常将签名证书的副本保存在子目录中(newcerts
或certs
,或keys
使用easyrsa。在脚本中您的权限或选项new_certs_dir
的openssl.cnf 文件中查找定义)。-outdir
因此,规范的做法是:
openssl ca -config openssl.cnf -revoke newcerts/hello-world.pem
但是,我添加这个答案是为了注意,对于当前版本,它openssl ca -revoke ...
似乎只更新index.txt
文件(它仍然会要求提供私钥密码,这是有问题的)所以如果你真的没有任何证书备份但仍然有或index.txt
某种方式来检索序列号,您可以查找/弥补证书行并更改它:
# before
V 291008172120Z 6DB67443D7E6C2D95D6E2F7F264C05F944964049 unknown /C=FR/CN=coucou.com
# after
R 291008172120Z 191011172218Z 6DB67443D7E6C2D95D6E2F7F264C05F944964049 unknown /C=FR/CN=coucou.com
# Format is 6 fields, tab-separated, and filename is usually 'unknown' :
# CRL doesn't contain nor need the subject so if unavailable, just make up something close
V/R/E expiration-date revocation-date serial-number filename subject
(使用 OpenSSL 1.1.1c 测试。在其他一些版本/环境中,序列号可以短得多)
这openssl ca -config openssl.cnf -gencrl -crldays 30 -out crl.pem
将是撤销证书的实际步骤,使用权威机构的私钥生成一个签名列表。