blob: 3809366ab74a1698872a3a243d5e46f3dfccc18d [file] [log] [blame]
William Lallemand2f52fdb2021-09-30 11:19:29 +02001#REGTEST_TYPE=devel
2
3# broken with BoringSSL.
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +02004
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
22varnishtest "Test the 'show ssl ocsp-response' and 'show ssl cert foo.pem.ocsp' features of the CLI"
Tim Duesterhus5efc48d2021-06-11 19:56:15 +020023feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
Tim Duesterhusc9570482021-06-11 19:56:16 +020024feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL)'"
William Lallemandf5429412021-09-30 18:45:18 +020025feature cmd "command -v socat && command -v openssl"
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +020026feature ignore_unknown_macro
27
28haproxy h1 -conf {
29 global
30 tune.ssl.default-dh-param 2048
Marcin Deranek310a2602021-07-13 19:04:24 +020031 tune.ssl.capture-buffer-size 1
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +020032 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
39 timeout connect 100ms
40 timeout client 1s
41 timeout server 1s
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
57haproxy 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
68haproxy 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"
85shell {
William Lallemand2655f2b2021-09-30 17:57:04 +020086 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 Breton2a77c622021-06-10 13:51:16 +020087}
88
89# Check that the change was taken into account
90haproxy 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
105shell {
106 printf "set ssl cert ${testdir}/show_ocsp_server.pem <<\n$(cat ${testdir}/show_ocsp_server.pem)\n\n" | socat "${tmpdir}/h1/stats" -
William Lallemand2655f2b2021-09-30 17:57:04 +0200107 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 Breton2a77c622021-06-10 13:51:16 +0200108}
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
113haproxy 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
127haproxy 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}