| 1 | ## Overview |
| 2 | The files in this directory represent a cert hierarchy to test OCSP response stapling. |
| 3 | |
| 4 | ## CA |
| 5 | - ca_cert.pem |
| 6 | - ca_key.pem |
| 7 | |
| 8 | Issuer for all of the other certs in the directory. |
| 9 | Since this is a test PKI, we do an intermediate for issuing leaf cert(s). |
| 10 | |
| 11 | ## OCSP |
| 12 | * ocsp_cert.pem |
| 13 | * ocsp_key.pem |
| 14 | |
| 15 | Cert/key for the test OCSP responder. OCSP responses will be signed by the key. |
| 16 | The CN for this cert matches the URI in the Server Cert's "Authority Information Access" x509 extension. |
| 17 | |
| 18 | ## Server Cert |
| 19 | * server_cert.pem |
| 20 | * server_key.pem |
| 21 | |
| 22 | The leaf cert/key. OCSP responses will be generated for this cert. |
| 23 | |
| 24 | ### Early Expiry Cert |
| 25 | The `server_cert_early_expire.pem` is a certificate that expires in 2037. This certificate is used to validate correct behavior of expired dates for unit tests on 32 bit platforms. This is necessary because 32 bit `time_t` values can't represent dates past 2038, so our unit tests on 32 bit platforms can't test the expiry of very long lived certs. |
| 26 | |
| 27 | This cert and the corresponding ocsp response, `ocsp_response_early_expire.der` can be generated at any time by running the `./generate.sh` script. This will break the `Test OCSP validation at various offsets from update times` unit test, because the "This Update" timestamp of `ocsp_response_early_expire.der` will change. |
| 28 | |
| 29 | This is fixed by setting `this_update_timestamp_nanoseconds` in `Test OCSP validation at various offsets from update times` to the new "This Update" timestamp. This can be found with |
| 30 | ``` |
| 31 | openssl ocsp -respin ocsp_response_early_expire.der -text -noverify | grep "This Update" |
| 32 | ``` |
| 33 | ## OCSP response |
| 34 | * ocsp_response.der |
| 35 | |
| 36 | DER formatted OCSP response for the Server Cert. This file will be configured in s2n for stapling. |
| 37 | |
| 38 | The OCSP responses can be viewed in plaintext using the `ocsp` command. |
| 39 | ``` |
| 40 | openssl ocsp -respin ocsp_response_early_expire.der -text -noverify |
| 41 | ``` |
| 42 | |
| 43 | ## Generating a new OCSP response for the leaf cert |
| 44 | Should not be necessary. The current response expires in 100 years. |
| 45 | |
| 46 | From the current directory: |
| 47 | |
| 48 | ### Run the server |
| 49 | ``` |
| 50 | # With nextUpdate |
| 51 | openssl ocsp -port 8889 -text -CA ca_cert.pem \ |
| 52 | -index certs.txt \ |
| 53 | -rkey ocsp_key.pem \ |
| 54 | -rsigner ocsp_cert.pem \ |
| 55 | -nrequest 1 \ |
| 56 | -ndays $(( 365 * 100 )) |
| 57 | |
| 58 | # Without nextUpdate |
| 59 | openssl ocsp -port 8890 -text -CA ca_cert.pem \ |
| 60 | -index certs.txt \ |
| 61 | -rkey ocsp_key.pem \ |
| 62 | -rsigner ocsp_cert.pem \ |
| 63 | -nrequest 1 |
| 64 | ``` |
| 65 | |
| 66 | ### Run the client and save the result to file |
| 67 | ``` |
| 68 | # With nextUpdate |
| 69 | openssl ocsp -CAfile ca_cert.pem \ |
| 70 | -url http://127.0.0.1:8889 \ |
| 71 | -issuer ca_cert.pem \ |
| 72 | -verify_other ocsp_cert.pem \ |
| 73 | -cert server_cert.pem -respout ocsp_response.der |
| 74 | # Without nextUpdate |
| 75 | openssl ocsp -CAfile ca_cert.pem \ |
| 76 | -url http://127.0.0.1:8890 \ |
| 77 | -issuer ca_cert.pem \ |
| 78 | -verify_other ocsp_cert.pem \ |
| 79 | -cert server_cert.pem -respout ocsp_response_no_next_update.der |
| 80 | ``` |
| 81 | |
| 82 | ### Generating ocsp_response_revoked.der |
| 83 | ``` |
| 84 | # Run responder |
| 85 | openssl ocsp -port 8889 -text -CA ca_cert.pem \ |
| 86 | -index certs_revoked.txt \ |
| 87 | -rkey ocsp_key.pem \ |
| 88 | -rsigner ocsp_cert.pem \ |
| 89 | -nrequest 1 -ndays $(( 365 * 100 )) |
| 90 | |
| 91 | # Run requester |
| 92 | openssl ocsp -CAfile ca_cert.pem \ |
| 93 | -url http://127.0.0.1:8889 \ |
| 94 | -issuer ca_cert.pem \ |
| 95 | -cert server_cert.pem \ |
| 96 | -respout ocsp_response_revoked.der |
| 97 | ``` |
| 98 | |
| 99 | ### Index Files |
| 100 | The index files in the previous commands are in the CA Database format, and are the source of truth for certificates being verified or rejected. |
| 101 | |
| 102 | > The index file consists of zero or more lines, each containing the following fields separated by tab characters: |
| 103 | > |
| 104 | > Certificate status flag (V=valid, R=revoked, E=expired). |
| 105 | > Certificate expiration date in YYMMDDHHMMSSZ format. |
| 106 | > Certificate revocation date in YYMMDDHHMMSSZ[,reason] format. Empty if not revoked. |
| 107 | > Certificate serial number in hex. |
| 108 | > Certificate filename or literal string ‘unknown’. |
| 109 | > Certificate distinguished name. |
| 110 | > -- https://pki-tutorial.readthedocs.io/en/latest/cadb.html |