SEC_ERROR_ADDING_CERT: Error adding certificate to database

3.7k Views Asked by At

While trying to configure a valid SSL certificate for localhost on Ubuntu, I got the following error:

certutil -d sql:$HOME/.pki/nssdb -A -t "CT,c,c" -n "localhost" -i localhost.crt

certutil: could not add certificate to token or database: SEC_ERROR_ADDING_CERT: Error adding certificate to database.

This certificate will be used in Nginx configuration, my goal is to avoid any errors in Google Chrome (ERR_SSL_PROTOCOL_ERROR) as the certificate authority is untrusted.

2

There are 2 best solutions below

0
On BEST ANSWER

This error occurred because the certificate was already registered using certutil previously.

Solution

  1. Delete the existing record

    certutil -n localhost -D localhost.crt

  2. Then, create a new record

    certutil -d sql:$HOME/.pki/nssdb -A -t "CT,c,c" -n "localhost" -i localhost.crt

0
On

For what its worth if anyone is suddenly getting this when trying to import a Let's Encrypt certificate you now need to point to the "fullchain.pem" file instead of the "chain.pem" file.