1+ -module (tls_client_optional_cert_SUITE ).
2+
3+ -include_lib (" common_test/include/ct.hrl" ).
4+
5+ -export ([all /0 , init_per_suite /1 , end_per_suite /1 ,
6+ connect_without_client_cert_test /1 , connect_with_client_cert_test /1 ]).
7+
8+ all () -> [connect_without_client_cert_test , connect_with_client_cert_test ].
9+
10+ init_per_suite (Config ) ->
11+ application :set_env (epp_proxy , require_client_certs , false ),
12+ application :ensure_all_started (epp_proxy ),
13+ application :ensure_all_started (hackney ),
14+ CWD = code :priv_dir (epp_proxy ),
15+ WithCert = [binary ,
16+ {certfile , filename :join (CWD , " test_ca/certs/client.crt.pem" )},
17+ {keyfile , filename :join (CWD , " test_ca/private/client.key.pem" )},
18+ {active , false }],
19+ [{with_cert , WithCert } | Config ].
20+
21+ end_per_suite (Config ) ->
22+ application :unset_env (epp_proxy , require_client_certs ),
23+ application :stop (epp_proxy ),
24+ application :stop (hackney ),
25+ Config .
26+
27+ connect_without_client_cert_test (_Config ) ->
28+ {ok , Socket } = ssl :connect (" localhost" , 1443 , [binary , {active , false }], 2000 ),
29+ {ok , _Data } = ssl :recv (Socket , 0 , 1200 ),
30+ ok .
31+
32+ connect_with_client_cert_test (Config ) ->
33+ Options = proplists :get_value (with_cert , Config ),
34+ {ok , Socket } = ssl :connect (" localhost" , 1443 , Options , 2000 ),
35+ {ok , _Data } = ssl :recv (Socket , 0 , 1200 ),
36+ ok .
0 commit comments