Remi Tricot-Le Breton | d12e13a | 2021-10-11 15:34:14 +0200 | [diff] [blame] | 1 | #REGTEST_TYPE=devel |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 2 | |
| 3 | # This reg-test checks that the connection and SSL sample fetches related to |
| 4 | # errors are functioning properly. It also tests the proper behaviour of the |
Remi Tricot-Le Breton | 1ac65f8 | 2021-10-11 15:34:11 +0200 | [diff] [blame] | 5 | # default HTTPS log format and of the error-log-format option which allows to |
| 6 | # define a specific log format used only in case of connection error (otherwise |
| 7 | # a line following the configured log-format is output). |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 8 | # |
| 9 | # It works by sending request through three different paths, one using a custom |
| 10 | # log-format line that contains the connection error and SSL handshake error |
| 11 | # sample fetches, one using the default HTTPS log-format and one using the |
| 12 | # legacy error log format. |
| 13 | # |
| 14 | # The output log lines are caught by syslog blocks (one for each path) and |
| 15 | # compared to an expected format. |
| 16 | # Since the syslog is not by design synchronized with the Varnish clients and |
| 17 | # servers, synchronization is achieved through barriers, which ensure that |
| 18 | # syslog messages arrive in the right order. |
| 19 | # |
Remi Tricot-Le Breton | 1ac65f8 | 2021-10-11 15:34:11 +0200 | [diff] [blame] | 20 | # In order to ensure that the log line raised in case of connection error if an |
| 21 | # error-log-format is defined still follows the log-separate-error option, the |
| 22 | # log lines raised by the https_fmt_lst listener will be sent to two separate |
| 23 | # syslog servers. |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 24 | # |
| 25 | |
| 26 | varnishtest "Test the connection and SSL error fetches." |
| 27 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev2)'" |
Remi Tricot-Le Breton | d12e13a | 2021-10-11 15:34:14 +0200 | [diff] [blame] | 28 | feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL) && ssllib_name_startswith(OpenSSL)'" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 29 | feature cmd "command -v socat" |
| 30 | feature ignore_unknown_macro |
| 31 | |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 32 | server s1 -repeat 4 { |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 33 | rxreq |
| 34 | txresp |
| 35 | } -start |
| 36 | |
| 37 | barrier b1 cond 4 -cyclic |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 38 | barrier b2 cond 2 -cyclic |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 39 | |
| 40 | |
| 41 | syslog Slg_cust_fmt -level info { |
| 42 | recv |
Remi Tricot-Le Breton | 74f6ab6 | 2021-08-19 18:06:30 +0200 | [diff] [blame] | 43 | expect ~ ".*conn_status:\"0:Success\" hsk_err:\"0:-\" CN=\"/C=FR/O=HAProxy Technologies/CN=Client\",serial=1007,hash=063DCC2E6A9159E66994B325D6D2EF3D17A75B6F" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 44 | |
| 45 | barrier b1 sync |
| 46 | |
| 47 | recv |
Remi Tricot-Le Breton | d266cda | 2021-10-11 15:34:13 +0200 | [diff] [blame] | 48 | expect ~ "ERROR.*conn_status:\"30:SSL client CA chain cannot be verified\" hsk_err:\"134:.*:certificate verify failed\" CN=\"/C=FR/O=HAProxy Technologies/CN=Client\",serial=1007,hash=063DCC2E6A9159E66994B325D6D2EF3D17A75B6F" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 49 | |
| 50 | barrier b1 sync |
| 51 | |
| 52 | recv |
Remi Tricot-Le Breton | d266cda | 2021-10-11 15:34:13 +0200 | [diff] [blame] | 53 | expect ~ "ERROR.*conn_status:\"31:SSL client certificate not trusted\" hsk_err:\"134:.*:certificate verify failed\" CN=\"/C=FR/O=HAProxy Technologies/CN=Client\",serial=1007,hash=063DCC2E6A9159E66994B325D6D2EF3D17A75B6F" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 54 | |
| 55 | barrier b1 sync |
| 56 | |
Ilya Shipitsin | bd6b4be | 2021-10-15 16:18:21 +0500 | [diff] [blame] | 57 | # In case of an error occurring before the certificate verification process, |
Remi Tricot-Le Breton | 74f6ab6 | 2021-08-19 18:06:30 +0200 | [diff] [blame] | 58 | # the client certificate chain is never parsed and verified so we can't |
| 59 | # have information about the client's certificate. |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 60 | recv |
Remi Tricot-Le Breton | d266cda | 2021-10-11 15:34:13 +0200 | [diff] [blame] | 61 | expect ~ "ERROR.*conn_status:\"34:SSL handshake failure\" hsk_err:\"193:.*:no shared cipher\" CN=\"\",serial=-,hash=-" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 62 | } -start |
| 63 | |
| 64 | syslog Slg_https_fmt -level info { |
| 65 | recv |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 66 | expect ~ ".*https_logfmt_ssl_lst~ https_logfmt_ssl_lst/s1.*0/0000000000000000/0/0/.? foo.com/TLSv1.2/AES256-GCM-SHA384" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 67 | |
| 68 | barrier b1 sync |
| 69 | } -start |
| 70 | |
| 71 | syslog Slg_https_fmt_err -level info { |
| 72 | recv |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 73 | expect ~ "ERROR.*https_logfmt_ssl_lst~ https_logfmt_ssl_lst/<NOSRV>.*30/0000000000000086/0/2/.? foo.com/TLSv1.2/\\(NONE\\)" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 74 | |
| 75 | barrier b1 sync |
| 76 | |
| 77 | recv |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 78 | expect ~ "ERROR.*https_logfmt_ssl_lst~ https_logfmt_ssl_lst/<NOSRV>.*31/0000000000000086/20/0/.? foo.com/TLSv1.2/\\(NONE\\)" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 79 | |
| 80 | barrier b1 sync |
| 81 | |
| 82 | recv |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 83 | expect ~ "ERROR.*https_logfmt_ssl_lst~ https_logfmt_ssl_lst/<NOSRV>.*34/00000000000000C1/0/0/.? foo.com/TLSv1.2/\\(NONE\\)" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 84 | } -start |
| 85 | |
| 86 | syslog Slg_logconnerror -level info { |
| 87 | recv |
| 88 | expect ~ ".*logconnerror_ssl_lst~ logconnerror_ssl_lst/s1" |
| 89 | |
| 90 | barrier b1 sync |
| 91 | |
| 92 | recv |
| 93 | expect ~ ".*logconnerror_ssl_lst/1: SSL client CA chain cannot be verified" |
| 94 | |
| 95 | barrier b1 sync |
| 96 | |
| 97 | recv |
| 98 | expect ~ ".*logconnerror_ssl_lst/1: SSL client certificate not trusted" |
| 99 | |
| 100 | barrier b1 sync |
| 101 | |
| 102 | recv |
| 103 | expect ~ ".*logconnerror_ssl_lst/1: SSL handshake failure" |
| 104 | } -start |
| 105 | |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 106 | syslog Slg_bcknd -level info { |
| 107 | recv |
Willy Tarreau | 6f74976 | 2021-11-05 17:07:03 +0100 | [diff] [blame] | 108 | expect ~ ".*bc_err:0:\"Success\" ssl_bc_err:0:" |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 109 | |
| 110 | barrier b2 sync |
| 111 | |
| 112 | recv |
Willy Tarreau | 6f74976 | 2021-11-05 17:07:03 +0100 | [diff] [blame] | 113 | expect ~ ".*bc_err:34:\"SSL handshake failure\" ssl_bc_err:134:.*:certificate verify failed" |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 114 | |
| 115 | barrier b2 sync |
| 116 | |
| 117 | recv |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 118 | expect ~ ".*bc_err:33:\"Server presented an SSL certificate different from the expected one\" ssl_bc_err:134:.*:certificate verify failed" |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 119 | |
| 120 | barrier b2 sync |
| 121 | |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 122 | # Verify errors on the server side cannot be caught when using TLSv1.3 but it works for TLSv1.2 |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 123 | recv |
Willy Tarreau | 6f74976 | 2021-11-05 17:07:03 +0100 | [diff] [blame] | 124 | expect ~ ".*bc_err:34:\"SSL handshake failure\" ssl_bc_err:1048:.*:tlsv1 alert unknown ca" |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 125 | |
| 126 | barrier b2 sync |
| 127 | |
| 128 | recv |
Remi Tricot-Le Breton | 85c0ff5 | 2022-04-21 12:06:42 +0200 | [diff] [blame] | 129 | expect ~ ".*bc_err:34:\"SSL handshake failure\" ssl_bc_err:1040:.* alert handshake failure" |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 130 | |
| 131 | barrier b2 sync |
| 132 | |
| 133 | recv |
Remi Tricot-Le Breton | 85c0ff5 | 2022-04-21 12:06:42 +0200 | [diff] [blame] | 134 | expect ~ ".*bc_err:34:\"SSL handshake failure\" ssl_bc_err:1040:.* alert handshake failure" |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 135 | } -start |
| 136 | |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 137 | syslog Slg_bcknd_fe -level info { |
| 138 | # Client c13 - No error |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 139 | # Depending on the version of OpenSSL, the TLS version and ciphersuite will change |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 140 | recv |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 141 | expect ~ ".* Server/(TLSv1.3/TLS_AES_256_GCM_SHA384|TLSv1.2/ECDHE-RSA-AES256-GCM-SHA384)" |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 142 | |
| 143 | # Client c14 - Server certificate rejected |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 144 | # Depending on the version of OpenSSL, the TLS version and ciphersuite will change |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 145 | recv |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 146 | expect ~ ".* foo.com/(TLSv1.3/TLS_AES_256_GCM_SHA384|TLSv1.2/\\(NONE\\))" |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 147 | |
| 148 | # Client c15 - Server certificate mismatch (verifyhost option on backend) |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 149 | # Depending on the version of OpenSSL, the TLS version and ciphersuite will change |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 150 | recv |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 151 | expect ~ ".* foo.com/(TLSv1.3/TLS_AES_256_GCM_SHA384|TLSv1.2/\\(NONE\\))" |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 152 | |
| 153 | # Client c16 - Client certificate rejected |
| 154 | recv |
| 155 | expect ~ ".* foo.com/TLSv1.2/\\(NONE\\)" |
| 156 | |
| 157 | # Client c17 - Wrong ciphers TLSv1.2 |
| 158 | recv |
| 159 | expect ~ ".* foo.com/TLSv1.2/\\(NONE\\)" |
| 160 | |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 161 | # Client c18 |
| 162 | # With OpenSSL1.0.2 -Wrong ciphers TLSv1.2 (same as c17) |
| 163 | # With newer versions - Wrong ciphers TLSv1.3 - the client does not get to send its certificate because the error happens before |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 164 | recv |
Remi Tricot-Le Breton | aab8d25 | 2022-01-11 17:29:24 +0100 | [diff] [blame] | 165 | expect ~ ".* (foo.com/TLSv1.2|-/TLSv1.3)/\\(NONE\\)" |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 166 | } -start |
| 167 | |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 168 | |
| 169 | haproxy h1 -conf { |
| 170 | global |
| 171 | tune.ssl.default-dh-param 2048 |
Marcin Deranek | 310a260 | 2021-07-13 19:04:24 +0200 | [diff] [blame] | 172 | tune.ssl.capture-buffer-size 1 |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 173 | stats socket "${tmpdir}/h1/stats" level admin |
Remi Tricot-Le Breton | d266cda | 2021-10-11 15:34:13 +0200 | [diff] [blame] | 174 | .if openssl_version_atleast(3.0.0) |
| 175 | set-var proc.ssl_error_mask str(7FFFFF),hex2i |
| 176 | .else |
| 177 | set-var proc.ssl_error_mask str(FFF),hex2i |
| 178 | .endif |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 179 | |
| 180 | defaults |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 181 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 182 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 183 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 184 | retries 0 |
| 185 | |
| 186 | listen clear_lst |
| 187 | bind "fd@${clearlst}" |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 188 | default-server ssl crt ${testdir}/set_cafile_client.pem ca-file ${testdir}/set_cafile_interCA2.crt verify none no-ssl-reuse force-tlsv12 sni str(foo.com) |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 189 | |
| 190 | balance roundrobin |
| 191 | server cust_fmt "${tmpdir}/cust_logfmt_ssl.sock" |
| 192 | server https_fmt "${tmpdir}/https_logfmt_ssl.sock" |
| 193 | server logconnerror "${tmpdir}/logconnerror_ssl.sock" |
| 194 | |
| 195 | |
| 196 | listen clear_wrong_ciphers_lst |
| 197 | bind "fd@${wrongcipherslst}" |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 198 | default-server ssl crt ${testdir}/set_cafile_client.pem ca-file ${testdir}/set_cafile_interCA2.crt verify none no-ssl-reuse force-tlsv12 ciphers "aECDSA" sni str(foo.com) |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 199 | |
| 200 | balance roundrobin |
| 201 | server cust_fmt "${tmpdir}/cust_logfmt_ssl.sock" |
| 202 | server https_fmt "${tmpdir}/https_logfmt_ssl.sock" |
| 203 | server logconnerror "${tmpdir}/logconnerror_ssl.sock" |
| 204 | |
| 205 | |
Willy Tarreau | 6f74976 | 2021-11-05 17:07:03 +0100 | [diff] [blame] | 206 | # This listener will be used to test backend fetches (bc_err and ssl_bc_err) |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 207 | listen clear_backend_errors_lst |
| 208 | bind "fd@${backenderrorslst}" |
| 209 | log ${Slg_bcknd_addr}:${Slg_bcknd_port} local0 |
Willy Tarreau | 6f74976 | 2021-11-05 17:07:03 +0100 | [diff] [blame] | 210 | log-format "bc_err:%[bc_err]:%{+Q}[bc_err_str]\ ssl_bc_err:%[ssl_bc_err,and(proc.ssl_error_mask)]:%{+Q}[ssl_bc_err_str]" |
| 211 | error-log-format "ERROR bc_err:%[bc_err]:%{+Q}[bc_err_str]\ ssl_bc_err:%[ssl_bc_err,and(proc.ssl_error_mask)]:%[ssl_bc_err_str]" |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 212 | |
| 213 | balance roundrobin |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 214 | server no_err "${tmpdir}/no_err_ssl.sock" ssl crt ${testdir}/set_cafile_client.pem ca-file ${testdir}/set_cafile_interCA2.crt verify required sni str(Server) |
| 215 | server srv_cert_rejected "${tmpdir}/srv_rejected_ssl.sock" ssl crt ${testdir}/set_cafile_client.pem ca-file ${testdir}/set_cafile_interCA1.crt verify required sni str(foo.com) |
| 216 | server mismatch_frontend "${tmpdir}/mismatch_fe_ssl.sock" ssl crt ${testdir}/set_cafile_client.pem ca-file ${testdir}/set_cafile_interCA2.crt verify required sni str(foo.com) verifyhost str(toto) # We force TLSv1.2 for this specific case because server-side |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 217 | # verification errors cannot be caught by the backend fetches when |
| 218 | # using TLSv1.3 |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 219 | server clt_cert_rejected "${tmpdir}/rejected_ssl.sock" ssl crt ${testdir}/set_cafile_client.pem ca-file ${testdir}/set_cafile_interCA2.crt verify none force-tlsv12 sni str(foo.com) |
| 220 | server wrong_ciphers "${tmpdir}/wrong_ciphers_ssl.sock" ssl verify none crt ${testdir}/client1.pem ca-file ${testdir}/ca-auth.crt force-tlsv12 ciphers "aECDSA" sni str(foo.com) |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 221 | |
| 222 | # No TLSv1.3 support with OpenSSL 1.0.2 so we duplicate the previous |
| 223 | # wrong cipher test in this case so that the error log remains the same |
| 224 | .if openssl_version_before(1.1.1) |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 225 | server wrong_ciphers2 "${tmpdir}/wrong_ciphers_ssl.sock" ssl verify none crt ${testdir}/client1.pem ca-file ${testdir}/ca-auth.crt force-tlsv12 ciphers "aECDSA" sni str(foo.com) |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 226 | .else |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 227 | server wrong_ciphers_tls13 "${tmpdir}/wrong_ciphers_tls13_ssl.sock" ssl verify none crt ${testdir}/client1.pem ca-file ${testdir}/ca-auth.crt ciphersuites "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256" force-tlsv13 sni str(foo.com) |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 228 | .endif |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 229 | |
| 230 | |
| 231 | |
| 232 | |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 233 | listen cust_logfmt_ssl_lst |
| 234 | log ${Slg_cust_fmt_addr}:${Slg_cust_fmt_port} local0 |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 235 | mode http |
Willy Tarreau | 6f74976 | 2021-11-05 17:07:03 +0100 | [diff] [blame] | 236 | log-format "conn_status:\"%[fc_err]:%[fc_err_str]\" hsk_err:\"%[ssl_fc_err]:%[ssl_fc_err_str]\" CN=%{+Q}[ssl_c_s_dn],serial=%[ssl_c_serial,hex],hash=%[ssl_c_sha1,hex]" |
| 237 | error-log-format "ERROR conn_status:\"%[fc_err]:%[fc_err_str]\" hsk_err:\"%[ssl_fc_err,and(proc.ssl_error_mask)]:%[ssl_fc_err_str]\" CN=%{+Q}[ssl_c_s_dn],serial=%[ssl_c_serial,hex],hash=%[ssl_c_sha1,hex]" |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 238 | bind "${tmpdir}/cust_logfmt_ssl.sock" ssl crt ${testdir}/set_cafile_server.pem ca-verify-file ${testdir}/set_cafile_rootCA.crt ca-file ${testdir}/set_cafile_interCA1.crt verify required ciphers "kRSA" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 239 | server s1 ${s1_addr}:${s1_port} |
| 240 | |
| 241 | listen https_logfmt_ssl_lst |
| 242 | log ${Slg_https_fmt_addr}:${Slg_https_fmt_port} local0 info |
| 243 | log ${Slg_https_fmt_err_addr}:${Slg_https_fmt_err_port} local0 err info |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 244 | option log-separate-errors |
| 245 | mode http |
| 246 | option httpslog |
Willy Tarreau | 68574dd | 2021-11-05 19:14:55 +0100 | [diff] [blame] | 247 | error-log-format "ERROR %ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r %[fc_err]/%[ssl_fc_err,and(proc.ssl_error_mask),hex]/%[ssl_c_err]/%[ssl_c_ca_err]/%[ssl_fc_is_resumed] %[ssl_fc_sni]/%sslv/%sslc" |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 248 | bind "${tmpdir}/https_logfmt_ssl.sock" ssl crt ${testdir}/set_cafile_server.pem ca-verify-file ${testdir}/set_cafile_rootCA.crt ca-file ${testdir}/set_cafile_interCA1.crt verify required ciphers "kRSA" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 249 | server s1 ${s1_addr}:${s1_port} |
| 250 | |
| 251 | listen logconnerror_ssl_lst |
| 252 | log ${Slg_logconnerror_addr}:${Slg_logconnerror_port} local0 info |
| 253 | mode http |
| 254 | option httplog |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 255 | bind "${tmpdir}/logconnerror_ssl.sock" ssl crt ${testdir}/set_cafile_server.pem ca-verify-file ${testdir}/set_cafile_rootCA.crt ca-file ${testdir}/set_cafile_interCA1.crt verify required ciphers "kRSA" |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 256 | server s1 ${s1_addr}:${s1_port} |
| 257 | |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 258 | |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 259 | |
| 260 | defaults bknd_err_dflt |
| 261 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 262 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 263 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 264 | retries 0 |
| 265 | log ${Slg_bcknd_fe_addr}:${Slg_bcknd_fe_port} local0 |
| 266 | log-format "%ci:%cp %[ssl_fc_sni]/%sslv/%sslc" |
| 267 | error-log-format "ERROR %ci:%cp %[ssl_fc_sni]/%sslv/%sslc" |
| 268 | |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 269 | # The following listeners allow to test backend error fetches |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 270 | listen no_backend_err_ssl_lst from bknd_err_dflt |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 271 | bind "${tmpdir}/no_err_ssl.sock" ssl crt ${testdir}/set_cafile_server.pem ca-file ${testdir}/set_cafile_interCA2.crt verify none |
| 272 | server s1 ${s1_addr}:${s1_port} |
| 273 | |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 274 | listen srv_rejected_ssl_lst from bknd_err_dflt |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 275 | bind "${tmpdir}/srv_rejected_ssl.sock" ssl crt ${testdir}/set_cafile_server.pem ca-file ${testdir}/set_cafile_interCA2.crt verify none |
| 276 | server s1 ${s1_addr}:${s1_port} |
| 277 | |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 278 | listen mismatch_fe_ssl_lst from bknd_err_dflt |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 279 | bind "${tmpdir}/mismatch_fe_ssl.sock" ssl crt ${testdir}/set_cafile_server.pem ca-file ${testdir}/set_cafile_interCA2.crt verify none |
| 280 | server s1 ${s1_addr}:${s1_port} |
| 281 | |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 282 | listen rejected_clt_ssl_lst from bknd_err_dflt |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 283 | bind "${tmpdir}/rejected_ssl.sock" ssl crt ${testdir}/set_cafile_server.pem ca-file ${testdir}/set_cafile_interCA2.crt verify required |
| 284 | server s1 ${s1_addr}:${s1_port} |
| 285 | |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 286 | listen wrong_ciphers_ssl_lst from bknd_err_dflt |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 287 | bind "${tmpdir}/wrong_ciphers_ssl.sock" ssl crt ${testdir}/common.pem ca-file ${testdir}/ca-auth.crt verify none force-tlsv12 ciphers "kRSA" |
| 288 | server s1 ${s1_addr}:${s1_port} |
| 289 | |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 290 | .if openssl_version_atleast(1.1.1) |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 291 | listen wrong_ciphers_tls13_ssl_lst from bknd_err_dflt |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 292 | bind "${tmpdir}/wrong_ciphers_tls13_ssl.sock" ssl crt ${testdir}/common.pem ca-file ${testdir}/ca-auth.crt verify none force-tlsv13 ciphersuites "TLS_AES_128_GCM_SHA256" |
| 293 | server s1 ${s1_addr}:${s1_port} |
Remi Tricot-Le Breton | e1b6109 | 2021-10-13 11:21:02 +0200 | [diff] [blame] | 294 | .endif |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 295 | |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 296 | } -start |
| 297 | |
| 298 | |
| 299 | # The three following requests should all succeed |
| 300 | client c1 -connect ${h1_clearlst_sock} { |
| 301 | txreq |
| 302 | rxresp |
| 303 | expect resp.status == 200 |
| 304 | } -run |
| 305 | |
| 306 | client c2 -connect ${h1_clearlst_sock} { |
| 307 | txreq |
| 308 | rxresp |
| 309 | expect resp.status == 200 |
| 310 | } -run |
| 311 | |
| 312 | client c3 -connect ${h1_clearlst_sock} { |
| 313 | txreq |
| 314 | rxresp |
| 315 | expect resp.status == 200 |
| 316 | } -run |
| 317 | |
| 318 | |
| 319 | barrier b1 sync |
| 320 | |
| 321 | |
| 322 | # Change the root CA in the frontends |
| 323 | shell { |
| 324 | printf "set ssl ca-file ${testdir}/set_cafile_rootCA.crt <<\n$(cat ${testdir}/set_cafile_interCA1.crt)\n\n" | socat "${tmpdir}/h1/stats" - |
| 325 | echo "commit ssl ca-file ${testdir}/set_cafile_rootCA.crt" | socat "${tmpdir}/h1/stats" - |
| 326 | } |
| 327 | |
| 328 | client c4 -connect ${h1_clearlst_sock} { |
| 329 | txreq |
| 330 | } -run |
| 331 | |
| 332 | client c5 -connect ${h1_clearlst_sock} { |
| 333 | txreq |
| 334 | } -run |
| 335 | |
| 336 | client c6 -connect ${h1_clearlst_sock} { |
| 337 | txreq |
| 338 | } -run |
| 339 | |
| 340 | barrier b1 sync |
| 341 | |
| 342 | |
| 343 | |
| 344 | # Restore the root CA |
| 345 | shell { |
| 346 | printf "set ssl ca-file ${testdir}/set_cafile_rootCA.crt <<\n$(cat ${testdir}/set_cafile_rootCA.crt)\n\n" | socat "${tmpdir}/h1/stats" - |
| 347 | echo "commit ssl ca-file ${testdir}/set_cafile_rootCA.crt" | socat "${tmpdir}/h1/stats" - |
| 348 | } |
| 349 | |
| 350 | # Change the intermediate CA in the frontends |
| 351 | shell { |
| 352 | printf "set ssl ca-file ${testdir}/set_cafile_interCA1.crt <<\n$(cat ${testdir}/set_cafile_interCA2.crt)\n\n" | socat "${tmpdir}/h1/stats" - |
| 353 | echo "commit ssl ca-file ${testdir}/set_cafile_interCA1.crt" | socat "${tmpdir}/h1/stats" - |
| 354 | } |
| 355 | |
| 356 | client c7 -connect ${h1_clearlst_sock} { |
| 357 | txreq |
| 358 | } -run |
| 359 | |
| 360 | client c8 -connect ${h1_clearlst_sock} { |
| 361 | txreq |
| 362 | } -run |
| 363 | |
| 364 | client c9 -connect ${h1_clearlst_sock} { |
| 365 | txreq |
| 366 | } -run |
| 367 | |
| 368 | barrier b1 sync |
| 369 | |
| 370 | |
| 371 | # Restore the intermediate CA in the frontends |
| 372 | shell { |
| 373 | printf "set ssl ca-file ${testdir}/set_cafile_interCA1.crt <<\n$(cat ${testdir}/set_cafile_interCA1.crt)\n\n" | socat "${tmpdir}/h1/stats" - |
| 374 | echo "commit ssl ca-file ${testdir}/set_cafile_interCA1.crt" | socat "${tmpdir}/h1/stats" - |
| 375 | } |
| 376 | |
| 377 | # "No shared cipher" errors |
| 378 | client c10 -connect ${h1_wrongcipherslst_sock} { |
| 379 | txreq |
| 380 | } -run |
| 381 | client c11 -connect ${h1_wrongcipherslst_sock} { |
| 382 | txreq |
| 383 | } -run |
| 384 | client c12 -connect ${h1_wrongcipherslst_sock} { |
| 385 | txreq |
| 386 | } -run |
| 387 | |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 388 | |
| 389 | shell { |
| 390 | printf "set ssl ca-file ${testdir}/set_cafile_interCA2.crt <<\n$(cat ${testdir}/set_cafile_interCA2.crt)\n$(cat ${testdir}/set_cafile_rootCA.crt)\n\n" | socat "${tmpdir}/h1/stats" - |
| 391 | echo "commit ssl ca-file ${testdir}/set_cafile_interCA2.crt" | socat "${tmpdir}/h1/stats" - |
| 392 | } |
| 393 | |
| 394 | client c13 -connect ${h1_backenderrorslst_sock} { |
| 395 | txreq |
| 396 | rxresp |
| 397 | expect resp.status == 200 |
| 398 | } -run |
| 399 | barrier b2 sync |
| 400 | client c14 -connect ${h1_backenderrorslst_sock} { |
| 401 | txreq |
| 402 | } -run |
| 403 | barrier b2 sync |
| 404 | client c15 -connect ${h1_backenderrorslst_sock} { |
| 405 | txreq |
| 406 | } -run |
| 407 | barrier b2 sync |
| 408 | client c16 -connect ${h1_backenderrorslst_sock} { |
| 409 | txreq |
| 410 | } -run |
| 411 | barrier b2 sync |
| 412 | client c17 -connect ${h1_backenderrorslst_sock} { |
| 413 | txreq |
| 414 | } -run |
| 415 | barrier b2 sync |
| 416 | client c18 -connect ${h1_backenderrorslst_sock} { |
| 417 | txreq |
| 418 | } -run |
| 419 | |
Remi Tricot-Le Breton | 54f6383 | 2021-07-29 09:45:54 +0200 | [diff] [blame] | 420 | syslog Slg_cust_fmt -wait |
| 421 | syslog Slg_https_fmt -wait |
| 422 | syslog Slg_https_fmt_err -wait |
| 423 | syslog Slg_logconnerror -wait |
Remi Tricot-Le Breton | b061fb3 | 2021-09-01 15:52:16 +0200 | [diff] [blame] | 424 | syslog Slg_bcknd -wait |
Remi Tricot-Le Breton | a996763 | 2022-01-07 17:12:01 +0100 | [diff] [blame] | 425 | syslog Slg_bcknd_fe -wait |