My work has decided to issue their own certificate authority (CA) to handle different aspects of our work securely without paying for certificates.

  • Cryptographically sign emails
  • Encrypt email contents
  • Make access to things like the company IRC client-certificate based.
  • Revoke the keys of former employees automatically

They sent me a .pem file, and I'm not sure how to add it to my Ubuntu install. The instructions sent were: "Double-clicking on it on a Mac should install it." 

How do I proceed? Do I need to do something with OpenSSL to create a .key, .csr, or .crt file?

share|improve this question

Installing a CA

Copy your certificate in PEM format (the format that has ----BEGIN CERTIFICATE---- in it) into /usr/local/share/ca-certificates and name it with a .crt file extension.

Then run sudo update-ca-certificates.

Caveats: This installation only affects products that use this certificate store. Some products may use other certificate stores; if you use those products, you'll need to add this CA certificate to those other certificate stores, too. (Firefox Instructions, Chrome Instructions, Java Instructions)

Testing The CA

You can verify if this worked by looking for the certificate that you just added in /etc/ssl/certs/ca-certificates.crt (which is just a long list of all of your trusted CA's concatenated together).

You can also use OpenSSL's s_client by trying to connect to a server that you know is using a certificate signed by the CA that you just installed.

$ openssl s_client -connect foo.whatever.com:443 -CApath /etc/ssl/certs

CONNECTED(00000003)
depth=1 C = US, ST = Virginia, O = "Whatever, Inc.", CN = whatever.com, emailAddress = admin@whatever.com
verify return:1
depth=0 C = US, ST = Virginia, L = Arlington, O = "Whatever, Inc.", CN = foo.whatever.com
verify return:1
---
Certificate chain
 0 s:/C=US/ST=Virginia/L=Arlington/O=Whatever, Inc./CN=foo.whatever.com
   i:/C=US/ST=Virginia/O=Whatever, Inc./CN=whatever.com/emailAddress=admin@whatever.com

... snip lots of output ...

    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1392837700
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)

The first thing to look for is the certificate chain near the top of the output. This should show the CA as the issuer (next to i:). This tells you that the server is presenting a certificate signed by the CA you're installing.

Second, look for the verify return code at the end to be set to 0 (ok).

share|improve this answer
1  
this one actually works – Sabareesh Kkanan Aug 4 '15 at 20:14
1  
Thanks for noting that firefox / chrome do not use the default cert store. – shokora Dec 10 '15 at 16:26
2  
Note that update-ca-certificates can be very finicky (probably by design). mycert.pem.crt did NOT work, but mycert.crt did. I also think that it needs to be /usr/local/share/ca-certificates, not /usr/share/ca-certificates (despite what comments said in the /etc/ca-certificates.conf). – labyrinth Dec 15 '15 at 17:39
    
Thanks for the crt extension comment, that was the secret to getting this work for me, I was given a cert with a cert extension and was confused as to why nothing was working. – Ransom Briggs Mar 29 '16 at 16:31
1  
One caveat: s_client doesn't send SNI by default and the server may need SNI especially if it supports virtual hosts/sites with different certs; for this case add -servername foo.whatever.com. Or if it's a web server use (modern versions of) curl or wget which do SNI automatically. – dave_thompson_085 May 14 '16 at 3:40

man update-ca-certificates:

update-ca-certificates  is  a  program  that  updates   the   directory
/etc/ssl/certs to hold SSL certificates and generates certificates.crt,
a concatenated single-file list of certificates.

It reads the file /etc/ca-certificates.conf. Each line gives a pathname
of  a  CA  certificate  under /usr/share/ca-certificates that should be
trusted.  Lines that begin with "#" are comment lines and thus ignored.
Lines  that  begin with "!" are deselected, causing the deactivation of
the CA certificate in question.

Furthermore   all   certificates   found   below   /usr/local/share/ca-
certificates are also included as implicitly trusted.

From the above, I would infer that the preferred way to get local certificate files into the trusted store is to put them into /usr/local/share/ca-certificates, and then run update-ca-certificates. You do not need to touch /etc/ssl/certs directly.

share|improve this answer
16  
Naming the certificates with .crt extensions seemed to be required as well. – phyzome Mar 5 '13 at 23:12
    
Thanks for the note @phyzome -- would not have been able to add my cert otherwise. – Seiyria Mar 17 '15 at 14:03

I had same issue, and I had to copy the .pem file to /usr/local/share/ca-certificates, renaming it as .crt. The .cer file can easily be converted to .pem, with openssl, for example, if you don't have the .pem.

After copying the file you must execute sudo update-ca-certificates.

share|improve this answer

The other answers regarding update-ca-certificates are correct for applications that read from the system certificate store. For Chrome and Firefox, and probably some others, the certificate must be put in the nssdb, the backend for the Mozilla NSS library.

From https://code.google.com/p/chromium/wiki/LinuxCertManagement:

For example, to trust a root CA certificate for issuing SSL server certificates, use

certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n <certificate nickname> -i <certificate filename>

Where <certificate nickname> is arbitrary, and <certificate filename> is your .pem or .crt file.

Other helpful references:

share|improve this answer
    
thanks. It works on Ubuntu 16.04 for Chrome 53.0.2785.143, but Firefox 49 seems to have separate store db and must be added from about:preferences#advanced [View Certiticates] -> [Authorities] -> [Import] More about firefox cert store. askubuntu.com/a/248326/535154 – mauron85 Oct 12 '16 at 12:31
    
By the way, if you want to install cert before first run of Chrome (i.e. while .pki/ dir is still missing), you must first create the nssdb: mkdir -p $HOME/.pki/nssdb && chmod -R 0700 $HOME/.pki && certutil -d sql:$HOME/.pki/nssdb -N --empty-password – akavel Dec 15 '16 at 16:21

For newer builds based on Debian, you may need to run:

sudo dpkg-reconfigure ca-certificates

NOTE: sudo dpkg-reconfigure ca-certificates calls update-ca-certificates internally

You'll of course still need to copy the certificate (.crt file) to /usr/share/ca-certificates before you do any of this :)

share|improve this answer

As noted, various applications using NSS have their own certificate store. As things stand on Ubuntu, you have to manually use certutil to add your CAs for each application, for each user.

In other distributions like Fedora, this kind of thing Just Works™ and you should file a bug against any applications which doesn't automatically trust the CAs you install with update-ca-trust.

You can fix this in Ubuntu too by installing the p11-kit-modules package and then replacing the NSS "built-in trust roots" module with p11-kit-trust.so, by making a symbolic link for example from /usr/lib/firefox/libnssckbi.so -> /usr/lib/x86_64-linux-gnu/pkcs11/p11-kit-trust.so

Then you will get the system's configured trust roots, not some hard-coded ones. Note that Ubuntu ships multiple different copies of that libnssckbi.so library with the hard-coded trust roots, and you have to replace all of them!

cf. https://bugs.launchpad.net/ubuntu/+source/nss/+bug/1647285

share|improve this answer

Seriously stupid answer to add here, but I had spent 2 hours going back and forth with certutils in linux... I was sure everything was correct:

hutber@hutber-mint /var/www/asos-mvt-framework $ certutil -L -d sql:${HOME}/.pki/nssdb

Certificate Nickname                                         Trust Attributes
                                                             SSL,S/MIME,JAR/XPI

anyproxy                                                     CT,, 
rootCA                                                       CT,, 
myasos                                                       CT,, 

But still, in chrome nothing was working. I tried everything, in the end....

Restarting Chrome

Was the key to my success after following: Steven Monday's advice

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.