Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SEC_ERROR_ADDING_CERT: Error adding certificate to database

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.

like image 741
Bruno Leveque Avatar asked Oct 25 '25 03:10

Bruno Leveque


1 Answers

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

like image 69
Bruno Leveque Avatar answered Oct 27 '25 01:10

Bruno Leveque