|
| 1 | +====================== |
| 2 | +creating a certificate |
| 3 | +====================== |
| 4 | + |
| 5 | +create a key |
| 6 | +^^^^^^^^^^^^ |
| 7 | + |
| 8 | +`2048` bit keys are probably good enough, but if you're paranoid `4096` is bigger. |
| 9 | + |
| 10 | +.. code-block:: console |
| 11 | +
|
| 12 | + openssl genrsa -aes256 -out key.key 2048 |
| 13 | +
|
| 14 | +create a certificate signing request (csr) |
| 15 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 16 | + |
| 17 | +This uses the key from the previous step. |
| 18 | + |
| 19 | +.. code-block:: console |
| 20 | +
|
| 21 | + openssl req -new -sha256 -key key.key -out csr.csr |
| 22 | +
|
| 23 | +
|
| 24 | +create a csr with a custom configuration |
| 25 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 26 | + |
| 27 | +Prepopulate the `CONFIG.cnf` with whatever settings you want. |
| 28 | +Use the key from the `create a key` step above. |
| 29 | + |
| 30 | +.. code-block:: console |
| 31 | +
|
| 32 | + openssl req -new -sha256 -config CONFIG.cnf -key key.key -out csr.csr |
| 33 | +
|
| 34 | +creating a key and csr in 1 step |
| 35 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 36 | + |
| 37 | +I like doing this in 2 steps, but to each their own. |
| 38 | + |
| 39 | +.. code-block::console |
| 40 | +
|
| 41 | + openssl req -newkey rsa:2048 -nodes -keyout NEWKEY.key -config CONFIG.cnf -out NEWCSR.csr -new -sha256 |
| 42 | +
|
| 43 | +create a self-signed certificate |
| 44 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 45 | + |
| 46 | +Expirations are getting shorter and shorter, hopefully 1 year will be good enough for a while. |
| 47 | + |
| 48 | +.. code-block:: console |
| 49 | +
|
| 50 | + openssl req -x509 -sha256 -days 365 -key key.key -in csr.csr -out certificate.crt |
| 51 | +
|
| 52 | +
|
| 53 | +ca: sign the csr |
| 54 | +^^^^^^^^^^^^^^^^ |
| 55 | + |
| 56 | +If you're silly and have your own certificate authority (ca), you can sign your own csr files. |
| 57 | + |
| 58 | +.. code-block:: console |
| 59 | +
|
| 60 | + openssl ca -batch -config intermediateCA-openssl.cnf -extensions server_cert -notext -in gitlab.csr -out gitlab.crt |
| 61 | +
|
| 62 | +ca: update the db |
| 63 | +^^^^^^^^^^^^^^^^^ |
| 64 | + |
| 65 | +This will expire certs in the db. |
| 66 | + |
| 67 | +.. code-block:: console |
| 68 | +
|
| 69 | + openssl ca -updatedb -config ./intermediateCA-openssl.cnf |
| 70 | +
|
| 71 | +ca: format of the index.txt file |
| 72 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 73 | + |
| 74 | +tab delimited |
| 75 | + |
| 76 | +1. Certificate status (V = valid, R = revoked, E = expired) |
| 77 | +2. Expiration date in YYMMDDHHMMSSZ format |
| 78 | +3. Cert revocation date |
| 79 | +4. serial number in hex |
| 80 | +5. filename or unknown |
| 81 | +6. Certificate distinguished name |
| 82 | + |
| 83 | + |
| 84 | +remove the passphrase form a key |
| 85 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 86 | + |
| 87 | +You probably shouldn't do this, but you can. |
| 88 | + |
| 89 | +.. code-block:: console |
| 90 | +
|
| 91 | + openssl rsa -in [file1.key] -out [file2.key] |
| 92 | +
|
0 commit comments