andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 1 | # Linux Cert Management |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 2 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 3 | **NOTE:** SSL client authentication with personal certificates does not work |
| 4 | completely in Linux, see [issue 16830](https://crbug.com/16830) and |
| 5 | [issue 25241](https://crbug.com/25241). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 6 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 7 | The easy way to manage certificates is navigate to chrome://settings/search#ssl. |
| 8 | Then click on the "Manage Certificates" button. This will load a built-in |
| 9 | interface for managing certificates. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 10 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 11 | On Linux, Chromium uses the |
| 12 | [NSS Shared DB](https://wiki.mozilla.org/NSS_Shared_DB_And_LINUX). If the |
| 13 | built-in manager does not work for you then you can configure certificates with |
| 14 | the |
| 15 | [NSS command line tools](http://www.mozilla.org/projects/security/pki/nss/tools/). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 16 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 17 | ## Details |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 18 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 19 | ### Get the tools |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 20 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 21 | * Debian/Ubuntu: `sudo apt-get install libnss3-tools` |
| 22 | * Fedora: `su -c "yum install nss-tools"` |
| 23 | * Gentoo: `su -c "echo 'dev-libs/nss utils' >> /etc/portage/package.use && |
| 24 | emerge dev-libs/nss"` (You need to launch all commands below with the `nss` |
| 25 | prefix, e.g., `nsscertutil`.) |
| 26 | * Opensuse: `sudo zypper install mozilla-nss-tools` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 27 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 28 | ### List all certificates |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 29 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 30 | certutil -d sql:$HOME/.pki/nssdb -L |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 31 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 32 | #### Ubuntu Jaunty error |
| 33 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 34 | Above (and most commands) gives: |
| 35 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 36 | certutil: function failed: security library: invalid arguments. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 37 | |
| 38 | Package version 3.12.3.1-0ubuntu0.9.04.2 |
| 39 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 40 | ### List details of a certificate |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 41 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 42 | certutil -d sql:$HOME/.pki/nssdb -L -n <certificate nickname> |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 43 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 44 | ### Add a certificate |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 45 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 46 | ```shell |
| 47 | certutil -d sql:$HOME/.pki/nssdb -A -t <TRUSTARGS> -n <certificate nickname> \ |
| 48 | -i <certificate filename> |
| 49 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 50 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 51 | The TRUSTARGS are three strings of zero or more alphabetic characters, separated |
| 52 | by commas. They define how the certificate should be trusted for SSL, email, and |
| 53 | object signing, and are explained in the |
| 54 | [certutil docs](http://www.mozilla.org/projects/security/pki/nss/tools/certutil.html#1034193) |
| 55 | or |
| 56 | [Meena's blog post on trust flags](https://blogs.oracle.com/meena/entry/notes_about_trust_flags). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 57 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 58 | For example, to trust a root CA certificate for issuing SSL server certificates, |
| 59 | use |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 60 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 61 | ```shell |
| 62 | certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n <certificate nickname> \ |
| 63 | -i <certificate filename> |
| 64 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 65 | |
| 66 | To import an intermediate CA certificate, use |
| 67 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 68 | ```shell |
| 69 | certutil -d sql:$HOME/.pki/nssdb -A -t ",," -n <certificate nickname> \ |
| 70 | -i <certificate filename> |
| 71 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 72 | |
| 73 | Note: to trust a self-signed server certificate, we should use |
| 74 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 75 | ``` |
| 76 | certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n <certificate nickname> \ |
| 77 | -i <certificate filename> |
| 78 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 79 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 80 | This should work now, because |
| 81 | [NSS bug 531160](https://bugzilla.mozilla.org/show_bug.cgi?id=531160) is claimed |
| 82 | to be fixed in a related bug report. If it doesn't work, then to work around |
| 83 | the NSS bug, you have to trust it as a CA using the "C,," trust flags. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 84 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 85 | #### Add a personal certificate and private key for SSL client authentication |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 86 | |
| 87 | Use the command: |
| 88 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 89 | pk12util -d sql:$HOME/.pki/nssdb -i PKCS12_file.p12 |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 90 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 91 | to import a personal certificate and private key stored in a PKCS #12 file. The |
| 92 | TRUSTARGS of the personal certificate will be set to "u,u,u". |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 93 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 94 | ### Delete a certificate |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 95 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 96 | certutil -d sql:$HOME/.pki/nssdb -D -n <certificate nickname> |