3

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.

Bruno Leveque
  • 2,647
  • 2
  • 23
  • 33

2 Answers2

3

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

Bruno Leveque
  • 2,647
  • 2
  • 23
  • 33
0

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.

Adambean
  • 1,096
  • 1
  • 9
  • 18