20

I work on Ubuntu 19. I have a .crt and a key file. I want to test my web app on https localhost.

I wanted to add crt file to Chrome (settings > advanced > manage certificates -> import ). So I tried to import the .crt file but I got is this:

"Certificate Import Error : The Private Key for this Client Certificate is missing or invalid"

I googled it, but I found nothing helpful.

I have also built the .pfx file (from .crt and key files) and imported it on chrome but I have error: "Your connection is not private"

I have also tested it by Firefox and Opera and get the same error.

pouriaZand
  • 211
  • 1
  • 2
  • 6
  • Was having a similar problem in Firefox, where it would not import a self-signed cert using Settings > Privacy & Security. The solution for me was to create a policies.json file pointing to the custom cert: https://stackoverflow.com/a/74802552/2657515 – JonathanDavidArndt Dec 14 '22 at 19:36

2 Answers2

23

I had the same issue, you should be adding it to 'Authorities' tab in Chrome browser. Authorities tab is for Self-Signed certs, whereas 'Your Certificates' tab is for identity certs.

Eshwar P
  • 379
  • 4
  • 13
  • 2
    Message states that the imported file is not a Certification Authority. – Mateja Petrovic Mar 16 '20 at 19:36
  • 1
    Refer also https://superuser.com/questions/1213287/private-key-is-missing-or-invalid-when-importing-a-certificate-in-google-chrom – Steven Jul 24 '20 at 10:52
  • I get error `Unknown algorithm pkcs12` for this command `sudo openssl req -x509 -nodes -days 18250 -newkey pkcs12 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt` – Fakhamatia Jul 13 '21 at 11:56
14

For properly importing the .crt and the .key into the nssdb database for Chrome I suggest you convert the client certificate + the private key into a PKCS12 certificate, for example:

openssl pkcs12 -export -inkey ./sample.key -in ./sample.crt -out ./sample.p12

Give it any export password you want, but write it down, because you'll need it later when importing.

After this, you can import the file "sample.p12" in the Chrome browser, using the tab 'Your Cerificates'.

plaurentiu
  • 141
  • 1
  • 3