blob: 849e8781ef77f8992c950fc2bd32add94ff5a686 [file] [log] [blame]
William Lallemand1d15f682020-04-28 21:52:38 +02001#REGTEST_TYPE=devel
2
3# This reg-test tests the client auth feature of HAProxy for both the backend
4# and frontend section with a CRL list
5#
6# This reg-test uses 2 chained listeners because vtest does not handle the SSL.
7# Test the frontend client auth and the backend side at the same time.
8#
9# The sends 3 requests one with a correct certificate, one with an expired one and one which was revoked.
10# The client then check if we received the right one with the right error.
11#
12# Certificates, CA and CRL are expiring in 2050 so it should be fine for the CI.
13#
14# Detail about configuration is explained there:
15# https://www.haproxy.com/blog/ssl-client-certificate-management-at-application-level/
16
17varnishtest "Test the client auth"
18#REQUIRE_VERSION=1.6
19#REQUIRE_OPTIONS=OPENSSL
20feature ignore_unknown_macro
21
22server s1 -repeat 3 {
23 rxreq
24 txresp
25} -start
26
27haproxy h1 -conf {
28 global
29 tune.ssl.default-dh-param 2048
30
31 defaults
32 mode http
33 option httplog
34 ${no-htx} option http-use-htx
35 log stderr local0 debug err
36 option logasap
37 timeout connect 1s
38 timeout client 1s
39 timeout server 1s
40
41 listen clear-lst
42 bind "fd@${clearlst}"
43 balance roundrobin
44 # crt: certificate sent for a client certificate request
45 server s1 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client1.pem
46 server s2 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client2_expired.pem # expired
47 server s3 "${tmpdir}/ssl.sock" ssl verify none crt ${testdir}/client3_revoked.pem # revoked
48
49 listen ssl-lst
50 # crt: certificate of the server
51 # ca-file: CA used for client authentication request
52 # crl-file: revocation list for client auth: the client1 certificate is revoked
53 bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/common.pem ca-file ${testdir}/ca-auth.crt verify optional crt-ignore-err all crl-file ${testdir}/crl-auth.pem
54
55 acl cert_expired ssl_c_verify 10
56 acl cert_revoked ssl_c_verify 23
57 acl cert_ok ssl_c_verify 0
58
59 http-response add-header X-SSL Ok if cert_ok
60 http-response add-header X-SSL Expired if cert_expired
61 http-response add-header X-SSL Revoked if cert_revoked
62
63 server s1 ${s1_addr}:${s1_port}
64} -start
65
66client c1 -connect ${h1_clearlst_sock} {
67 txreq
68 rxresp
69 expect resp.status == 200
70 expect resp.http.x-ssl == "Ok"
71} -run
72
73client c1 -connect ${h1_clearlst_sock} {
74 txreq
75 rxresp
76 expect resp.status == 200
77 expect resp.http.x-ssl == "Expired"
78} -run
79
80client c1 -connect ${h1_clearlst_sock} {
81 txreq
82 rxresp
83 expect resp.status == 200
84 expect resp.http.x-ssl == "Revoked"
85} -run