3 SSL testcases are configured in the `ssl-tests` directory.
5 Each `ssl_*.conf.in` file contains a number of test configurations. These files
6 are used to generate testcases in the OpenSSL CONF format.
8 The precise test output can be dependent on the library configuration. The test
9 harness generates the output files on the fly.
11 However, for verification, we also include checked-in configuration outputs
12 corresponding to the default configuration. These testcases live in
13 `test/ssl-tests/*.conf` files.
15 For more details, see `ssl-tests/01-simple.conf.in` for an example.
17 ## Configuring the test
19 First, give your test a name. The names do not have to be unique.
21 An example test input looks like this:
25 name => "test-default",
26 server => { "CipherString" => "DEFAULT" },
27 client => { "CipherString" => "DEFAULT" },
28 test => { "ExpectedResult" => "Success" },
32 The test section supports the following options
36 * Method - the method to test. One of DTLS or TLS.
38 * HandshakeMode - which handshake flavour to test:
39 - Simple - plain handshake (default)
40 - Resume - test resumption
41 - RenegotiateServer - test server initiated renegotiation
42 - RenegotiateClient - test client initiated renegotiation
44 When HandshakeMode is Resume or Renegotiate, the original handshake is expected
45 to succeed. All configured test expectations are verified against the second
48 * ApplicationData - amount of application data bytes to send (integer, defaults
49 to 256 bytes). Applies to both client and server. Application data is sent in
50 64kB chunks (but limited by MaxFragmentSize and available parallelization, see
53 * MaxFragmentSize - maximum send fragment size (integer, defaults to 512 in
54 tests - see `SSL_CTX_set_max_send_fragment` for documentation). Applies to
55 both client and server. Lowering the fragment size will split handshake and
56 application data up between more `SSL_write` calls, thus allowing to exercise
57 different code paths. In particular, if the buffer size (64kB) is at least
58 four times as large as the maximum fragment, interleaved multi-buffer crypto
59 implementations may be used on some platforms.
63 * ExpectedResult - expected handshake outcome. One of
64 - Success - handshake success
65 - ServerFail - serverside handshake failure
66 - ClientFail - clientside handshake failure
67 - InternalError - some other error
69 * ExpectedClientAlert, ExpectedServerAlert - expected alert. See
70 `ssl_test_ctx.c` for known values. Note: the expected alert is currently
71 matched against the _last_ received alert (i.e., a fatal alert or a
72 `close_notify`). Warning alert expectations are not yet supported. (A warning
73 alert will not be correctly matched, if followed by a `close_notify` or
76 * ExpectedProtocol - expected negotiated protocol. One of
77 SSLv3, TLSv1, TLSv1.1, TLSv1.2.
79 * SessionTicketExpected - whether or not a session ticket is expected
80 - Ignore - do not check for a session ticket (default)
81 - Yes - a session ticket is expected
82 - No - a session ticket is not expected
84 * ResumptionExpected - whether or not resumption is expected (Resume mode only)
85 - Yes - resumed handshake
86 - No - full handshake (default)
88 * ExpectedNPNProtocol, ExpectedALPNProtocol - NPN and ALPN expectations.
90 * ExpectedTmpKeyType - the expected algorithm or curve of server temp key
92 * ExpectedServerKeyType, ExpectedClientKeyType - the expected algorithm or
93 curve of server or client certificate
95 ## Configuring the client and server
97 The client and server configurations can be any valid `SSL_CTX`
98 configurations. For details, see the manpages for `SSL_CONF_cmd`.
100 Give your configurations as a dictionary of CONF commands, e.g.
104 "CipherString" => "DEFAULT",
105 "MinProtocol" => "TLSv1",
109 The following sections may optionally be defined:
111 * server2 - this section configures a secondary context that is selected via the
112 ServerName test option. This context is used whenever a ServerNameCallback is
113 specified. If the server2 section is not present, then the configuration
115 * resume_server - this section configures the client to resume its session
116 against a different server. This context is used whenever HandshakeMode is
117 Resume. If the resume_server section is not present, then the configuration
119 * resume_client - this section configures the client to resume its session with
120 a different configuration. In practice this may occur when, for example,
121 upgraded clients reuse sessions persisted on disk. This context is used
122 whenever HandshakeMode is Resume. If the resume_client section is not present,
123 then the configuration matches client.
125 ### Configuring callbacks and additional options
127 Additional handshake settings can be configured in the `extra` section of each
132 "CipherString" => "DEFAULT",
134 "ServerName" => "server2",
139 #### Supported client-side options
141 * ClientVerifyCallback - the client's custom certificate verify callback.
142 Used to test callback behaviour. One of
143 - None - no custom callback (default)
144 - AcceptAll - accepts all certificates.
145 - RejectAll - rejects all certificates.
147 * ServerName - the server the client should attempt to connect to. One of
148 - None - do not use SNI (default)
149 - server1 - the initial context
150 - server2 - the secondary context
151 - invalid - an unknown context
153 * CTValidation - Certificate Transparency validation strategy. One of
154 - None - no validation (default)
155 - Permissive - SSL_CT_VALIDATION_PERMISSIVE
156 - Strict - SSL_CT_VALIDATION_STRICT
158 #### Supported server-side options
160 * ServerNameCallback - the SNI switching callback to use
161 - None - no callback (default)
162 - IgnoreMismatch - continue the handshake on SNI mismatch
163 - RejectMismatch - abort the handshake on SNI mismatch
165 * BrokenSessionTicket - a special test case where the session ticket callback
166 does not initialize crypto.
170 #### Mutually supported options
172 * NPNProtocols, ALPNProtocols - NPN and ALPN settings. Server and client
173 protocols can be specified as a comma-separated list, and a callback with the
174 recommended behaviour will be installed automatically.
176 ### Default server and client configurations
178 The default server certificate and CA files are added to the configurations
179 automatically. Server certificate verification is requested by default.
181 You can override these options by redefining them:
185 "VerifyCAFile" => "/path/to/custom/file"
193 "VerifyCAFile" => undef
197 ## Adding a test to the test harness
199 1. Add a new test configuration to `test/ssl-tests`, following the examples of
200 existing `*.conf.in` files (for example, `01-simple.conf.in`).
202 2. Generate the generated `*.conf` test input file. You can do so by running
203 `generate_ssl_tests.pl`:
208 $ TOP=.. perl -I testlib/ generate_ssl_tests.pl ssl-tests/my.conf.in \
212 where `my.conf.in` is your test input file.
214 For example, to generate the test cases in `ssl-tests/01-simple.conf.in`, do
217 $ TOP=.. perl -I testlib/ generate_ssl_tests.pl ssl-tests/01-simple.conf.in > ssl-tests/01-simple.conf
220 Alternatively (hackish but simple), you can comment out
223 unlink glob $tmp_file;
226 in `test/recipes/80-test_ssl_new.t` and run
229 $ make TESTS=test_ssl_new test
232 This will save the generated output in a `*.tmp` file in the build directory.
234 3. Update the number of tests planned in `test/recipes/80-test_ssl_new.t`. If
235 the test suite has any skip conditions, update those too (see
236 `test/recipes/80-test_ssl_new.t` for details).
238 ## Running the tests with the test harness
241 HARNESS_VERBOSE=yes make TESTS=test_ssl_new test
244 ## Running a test manually
246 These steps are only needed during development. End users should run `make test`
247 or follow the instructions above to run the SSL test suite.
249 To run an SSL test manually from the command line, the `TEST_CERTS_DIR`
250 environment variable to point to the location of the certs. E.g., from the root
251 OpenSSL directory, do
254 $ CTLOG_FILE=test/ct/log_list.conf TEST_CERTS_DIR=test/certs test/ssl_test \
255 test/ssl-tests/01-simple.conf
261 $ CTLOG_FILE=test/ct/log_list.conf TEST_CERTS_DIR=test/certs \
262 util/shlib_wrap.sh test/ssl_test test/ssl-tests/01-simple.conf
265 Note that the test expectations sometimes depend on the Configure settings. For
266 example, the negotiated protocol depends on the set of available (enabled)
267 protocols: a build with `enable-ssl3` has different test expectations than a
268 build with `no-ssl3`.
270 The Perl test harness automatically generates expected outputs, so users who
271 just run `make test` do not need any extra steps.
273 However, when running a test manually, keep in mind that the repository version
274 of the generated `test/ssl-tests/*.conf` correspond to expected outputs in with
275 the default Configure options. To run `ssl_test` manually from the command line
276 in a build with a different configuration, you may need to generate the right
277 `*.conf` file from the `*.conf.in` input first.