Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to revoke an openssl certificate when you don't have the certificate

I made an openssl certificate signed by the CA created on the local machine.

This certificate was deleted and I don't have it anymore.

It is impossible to create another certificate with the same commonName because openssl doesn't allow it and will generate the error:

failed to update database TXT_DB error number 2 

How can I revoke the certificate to create another one with the same commonName ?

like image 489
leszek.hanusz Avatar asked Feb 29 '12 09:02

leszek.hanusz


People also ask

Can a certificate be revoked?

A certificate should be revoked immediately when its private key shows signs of being compromised. It should also be revoked when the domain for which it was issued is no longer operational.


2 Answers

(Based on Nilesh's answer) In the default configuration, openssl will keep copies of all signed certificates in /etc/ssl/newcerts, named by its index number. So grep /etc/ssl/index.txt to obtain the serial number of the key to be revoked, e.g. 1013, then execute the following command:

openssl ca -revoke /etc/ssl/newcerts/1013.pem #replacing the serial number 

The -keyfile and -cert mentioned in Nilesh's answer are only required if that deviates from your openssl.cnf settings.


Alternatively you can also change /etc/ssl/index.txt.attr to contain the line

unique_subject = no 

to allow multiple certificates with the same common name. If you have published the original certificate, revoking the old one is however the preferable solution, even if you don't run an OSCP server or provide CRLs.

like image 85
Tobias Kienzler Avatar answered Oct 03 '22 10:10

Tobias Kienzler


I haven't tried this but it looks like you need something like this.

openssl ca -revoke bad_crt_file -keyfile ca_key -cert ca_crt 

openssl automatically saves a copy of your cert at newcerts directory. You may want to check it to retrieve your certificate. Unfortunately you need a certificate present to revoke it. See the following for details: http://www.mad-hacking.net/documentation/linux/security/ssl-tls/revoking-certificate.xml

like image 33
Nilesh Avatar answered Oct 03 '22 10:10

Nilesh