William Lallemand | 2f52fdb | 2021-09-30 11:19:29 +0200 | [diff] [blame] | 1 | #REGTEST_TYPE=devel |
| 2 | |
| 3 | # broken with BoringSSL. |
Remi Tricot-Le Breton | 2a77c62 | 2021-06-10 13:51:16 +0200 | [diff] [blame] | 4 | |
| 5 | # This reg-test uses the "show ssl ocsp-response" command to display the details |
| 6 | # of the OCSP responses used by HAProxy. |
| 7 | # It also uses the new special cases of the "show ssl cert" command, where an OCSP |
| 8 | # extension is provided to the certificate name (with or without preceding * for an |
| 9 | # ongoing transaction). |
| 10 | # |
| 11 | # It uses the show_ocsp_server.pem server certificate, signed off by set_cafile_rootCA.crt, |
| 12 | # which has two OCSP responses, show_ocsp_server.pem.ocsp which is loaded by default and in |
| 13 | # which it is valid, and show_ocsp_server.pem.ocsp.revoked in which it is revoked. |
| 14 | # The OSCP response is updated through the two means available in the CLI, the |
| 15 | # "set ssl ocsp-response" command and the update through a "set ssl cert foo.ocsp". |
| 16 | # |
| 17 | # It requires socat to upload the new OCSP responses. |
| 18 | # |
| 19 | # If this test does not work anymore: |
| 20 | # - Check that you have socat |
| 21 | |
| 22 | varnishtest "Test the 'show ssl ocsp-response' and 'show ssl cert foo.pem.ocsp' features of the CLI" |
Tim Duesterhus | 5efc48d | 2021-06-11 19:56:15 +0200 | [diff] [blame] | 23 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'" |
Ilya Shipitsin | 8de3eff | 2022-01-31 09:49:47 +0500 | [diff] [blame] | 24 | feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL) && !ssllib_name_startswith(BoringSSL)'" |
William Lallemand | f542941 | 2021-09-30 18:45:18 +0200 | [diff] [blame] | 25 | feature cmd "command -v socat && command -v openssl" |
Remi Tricot-Le Breton | 2a77c62 | 2021-06-10 13:51:16 +0200 | [diff] [blame] | 26 | feature ignore_unknown_macro |
| 27 | |
| 28 | haproxy h1 -conf { |
| 29 | global |
| 30 | tune.ssl.default-dh-param 2048 |
Marcin Deranek | 310a260 | 2021-07-13 19:04:24 +0200 | [diff] [blame] | 31 | tune.ssl.capture-buffer-size 1 |
Remi Tricot-Le Breton | 2a77c62 | 2021-06-10 13:51:16 +0200 | [diff] [blame] | 32 | stats socket "${tmpdir}/h1/stats" level admin |
| 33 | |
| 34 | defaults |
| 35 | mode http |
| 36 | option httplog |
| 37 | log stderr local0 debug err |
| 38 | option logasap |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 39 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 40 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 41 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Remi Tricot-Le Breton | 2a77c62 | 2021-06-10 13:51:16 +0200 | [diff] [blame] | 42 | |
| 43 | listen clear-lst |
| 44 | bind "fd@${clearlst}" |
| 45 | server s1 "${tmpdir}/ssl.sock" ssl ca-file ${testdir}/set_cafile_rootCA.crt verify none |
| 46 | |
| 47 | listen ssl-lst |
| 48 | # crt: certificate of the server |
| 49 | # ca-file: CA used for client authentication request |
| 50 | bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/show_ocsp_server.pem ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all |
| 51 | http-response add-header X-SSL-Client-Verify %[ssl_c_verify] |
| 52 | server s1 ${s1_addr}:${s1_port} |
| 53 | } -start |
| 54 | |
| 55 | |
| 56 | # Test the "show ssl ocsp-response" command |
| 57 | haproxy h1 -cli { |
| 58 | send "show ssl ocsp-response" |
| 59 | expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 60 | |
| 61 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 62 | expect ~ "Responder Id: C = FR, O = HAProxy Technologies, CN = ocsp.haproxy.com" |
| 63 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 64 | expect ~ "Cert Status: good" |
| 65 | } |
| 66 | |
| 67 | # Test the "show ssl cert foo.pem.ocsp" command |
| 68 | haproxy h1 -cli { |
| 69 | send "show ssl cert" |
| 70 | expect ~ ".*show_ocsp_server.pem" |
| 71 | |
| 72 | send "show ssl cert ${testdir}/show_ocsp_server.pem" |
| 73 | expect ~ "Serial: 100F" |
| 74 | send "show ssl cert ${testdir}/show_ocsp_server.pem" |
| 75 | expect ~ "OCSP Response Key: 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 76 | |
| 77 | send "show ssl cert ${testdir}/show_ocsp_server.pem.ocsp" |
| 78 | expect ~ "Responder Id: C = FR, O = HAProxy Technologies, CN = ocsp.haproxy.com" |
| 79 | send "show ssl cert ${testdir}/show_ocsp_server.pem.ocsp" |
| 80 | expect ~ "Cert Status: good" |
| 81 | } |
| 82 | |
| 83 | |
| 84 | # Change the server certificate's OCSP response through "set ssl ocsp-response" |
| 85 | shell { |
William Lallemand | 2655f2b | 2021-09-30 17:57:04 +0200 | [diff] [blame] | 86 | printf "set ssl ocsp-response <<\n$(cat ${testdir}/show_ocsp_server.pem.ocsp.revoked|openssl base64)\n\n" | socat "${tmpdir}/h1/stats" - |
Remi Tricot-Le Breton | 2a77c62 | 2021-06-10 13:51:16 +0200 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | # Check that the change was taken into account |
| 90 | haproxy h1 -cli { |
| 91 | send "show ssl ocsp-response" |
| 92 | expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 93 | |
| 94 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 95 | expect ~ "Responder Id: C = FR, O = HAProxy Technologies, CN = ocsp.haproxy.com" |
| 96 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 97 | expect ~ "Cert Status: revoked" |
| 98 | |
| 99 | send "show ssl cert ${testdir}/show_ocsp_server.pem.ocsp" |
| 100 | expect ~ "Cert Status: revoked" |
| 101 | } |
| 102 | |
| 103 | |
| 104 | # Change the server certificate's OCSP response through a transaction |
| 105 | shell { |
| 106 | printf "set ssl cert ${testdir}/show_ocsp_server.pem <<\n$(cat ${testdir}/show_ocsp_server.pem)\n\n" | socat "${tmpdir}/h1/stats" - |
William Lallemand | 2655f2b | 2021-09-30 17:57:04 +0200 | [diff] [blame] | 107 | printf "set ssl cert ${testdir}/show_ocsp_server.pem.ocsp <<\n$(cat ${testdir}/show_ocsp_server.pem.ocsp|openssl base64)\n\n" | socat "${tmpdir}/h1/stats" - |
Remi Tricot-Le Breton | 2a77c62 | 2021-06-10 13:51:16 +0200 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | |
| 111 | # Check that the actual tree entry was not changed and that the uncommitted |
| 112 | # transaction's OCSP response is the new one |
| 113 | haproxy h1 -cli { |
| 114 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 115 | expect ~ "Cert Status: revoked" |
| 116 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 117 | expect ~ "This Update: Jun 10 08:57:45 2021 GMT" |
| 118 | |
| 119 | send "show ssl cert *${testdir}/show_ocsp_server.pem.ocsp" |
| 120 | expect ~ "Cert Status: good" |
| 121 | send "show ssl cert *${testdir}/show_ocsp_server.pem.ocsp" |
| 122 | expect ~ "This Update: Jun 10 08:55:04 2021 GMT" |
| 123 | } |
| 124 | |
| 125 | |
| 126 | # Commit the transaction and check that it was taken into account |
| 127 | haproxy h1 -cli { |
| 128 | send "commit ssl cert ${testdir}/show_ocsp_server.pem" |
| 129 | expect ~ "Success!" |
| 130 | |
| 131 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 132 | expect ~ "Cert Status: good" |
| 133 | send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f" |
| 134 | expect ~ "This Update: Jun 10 08:55:04 2021 GMT" |
| 135 | } |