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. Therefore, whenever you're adding or updating a
14 generated test, you should run
19 $ TOP=.. perl -I testlib/ generate_ssl_tests.pl ssl-tests/my.conf.in \
23 where `my.conf.in` is your test input file.
25 For example, to generate the test cases in `ssl-tests/01-simple.conf.in`, do
28 $ TOP=.. perl generate_ssl_tests.pl ssl-tests/01-simple.conf.in > ssl-tests/01-simple.conf
31 For more details, see `ssl-tests/01-simple.conf.in` for an example.
33 ## Configuring the test
35 First, give your test a name. The names do not have to be unique.
37 An example test input looks like this:
41 name => "test-default",
42 server => { "CipherString" => "DEFAULT" },
43 client => { "CipherString" => "DEFAULT" },
44 test => { "ExpectedResult" => "Success" },
48 The test section supports the following options
52 * Method - the method to test. One of DTLS or TLS.
54 * HandshakeMode - which handshake flavour to test:
55 - Simple - plain handshake (default)
56 - Resume - test resumption
57 - (Renegotiate - test renegotiation, not yet implemented)
59 When HandshakeMode is Resume or Renegotiate, the original handshake is expected
60 to succeed. All configured test expectations are verified against the second
63 * ApplicationData - amount of application data bytes to send (integer, defaults
64 to 256 bytes). Applies to both client and server. Application data is sent in
65 64kB chunks (but limited by MaxFragmentSize and available parallelization, see
68 * MaxFragmentSize - maximum send fragment size (integer, defaults to 512 in
69 tests - see `SSL_CTX_set_max_send_fragment` for documentation). Applies to
70 both client and server. Lowering the fragment size will split handshake and
71 application data up between more `SSL_write` calls, thus allowing to exercise
72 different code paths. In particular, if the buffer size (64kB) is at least
73 four times as large as the maximum fragment, interleaved multi-buffer crypto
74 implementations may be used on some platforms.
78 * ExpectedResult - expected handshake outcome. One of
79 - Success - handshake success
80 - ServerFail - serverside handshake failure
81 - ClientFail - clientside handshake failure
82 - InternalError - some other error
84 * ExpectedClientAlert, ExpectedServerAlert - expected alert. See
85 `ssl_test_ctx.c` for known values. Note: the expected alert is currently
86 matched against the _last_ received alert (i.e., a fatal alert or a
87 `close_notify`). Warning alert expectations are not yet supported. (A warning
88 alert will not be correctly matched, if followed by a `close_notify` or
91 * ExpectedProtocol - expected negotiated protocol. One of
92 SSLv3, TLSv1, TLSv1.1, TLSv1.2.
94 * SessionTicketExpected - whether or not a session ticket is expected
95 - Ignore - do not check for a session ticket (default)
96 - Yes - a session ticket is expected
97 - No - a session ticket is not expected
99 * ResumptionExpected - whether or not resumption is expected (Resume mode only)
100 - Yes - resumed handshake
101 - No - full handshake (default)
103 * ExpectedNPNProtocol, ExpectedALPNProtocol - NPN and ALPN expectations.
105 ## Configuring the client and server
107 The client and server configurations can be any valid `SSL_CTX`
108 configurations. For details, see the manpages for `SSL_CONF_cmd`.
110 Give your configurations as a dictionary of CONF commands, e.g.
114 "CipherString" => "DEFAULT",
115 "MinProtocol" => "TLSv1",
119 The following sections may optionally be defined:
121 * server2 - this section configures a secondary context that is selected via the
122 ServerName test option. This context is used whenever a ServerNameCallback is
123 specified. If the server2 section is not present, then the configuration
125 * resume_server - this section configures the client to resume its session
126 against a different server. This context is used whenever HandshakeMode is
127 Resume. If the resume_server section is not present, then the configuration
129 * resume_client - this section configures the client to resume its session with
130 a different configuration. In practice this may occur when, for example,
131 upgraded clients reuse sessions persisted on disk. This context is used
132 whenever HandshakeMode is Resume. If the resume_client section is not present,
133 then the configuration matches client.
135 ### Configuring callbacks and additional options
137 Additional handshake settings can be configured in the `extra` section of each
142 "CipherString" => "DEFAULT",
144 "ServerName" => "server2",
149 #### Supported client-side options
151 * ClientVerifyCallback - the client's custom certificate verify callback.
152 Used to test callback behaviour. One of
153 - None - no custom callback (default)
154 - AcceptAll - accepts all certificates.
155 - RejectAll - rejects all certificates.
157 * ServerName - the server the client should attempt to connect to. One of
158 - None - do not use SNI (default)
159 - server1 - the initial context
160 - server2 - the secondary context
161 - invalid - an unknown context
163 * CTValidation - Certificate Transparency validation strategy. One of
164 - None - no validation (default)
165 - Permissive - SSL_CT_VALIDATION_PERMISSIVE
166 - Strict - SSL_CT_VALIDATION_STRICT
168 #### Supported server-side options
170 * ServerNameCallback - the SNI switching callback to use
171 - None - no callback (default)
172 - IgnoreMismatch - continue the handshake on SNI mismatch
173 - RejectMismatch - abort the handshake on SNI mismatch
175 * BrokenSessionTicket - a special test case where the session ticket callback
176 does not initialize crypto.
180 #### Mutually supported options
182 * NPNProtocols, ALPNProtocols - NPN and ALPN settings. Server and client
183 protocols can be specified as a comma-separated list, and a callback with the
184 recommended behaviour will be installed automatically.
186 ### Default server and client configurations
188 The default server certificate and CA files are added to the configurations
189 automatically. Server certificate verification is requested by default.
191 You can override these options by redefining them:
195 "VerifyCAFile" => "/path/to/custom/file"
203 "VerifyCAFile" => undef
207 ## Adding a test to the test harness
209 Add your configuration file to `test/recipes/80-test_ssl_new.t`.
211 ## Running the tests with the test harness
214 HARNESS_VERBOSE=yes make TESTS=test_ssl_new test
217 ## Running a test manually
219 These steps are only needed during development. End users should run `make test`
220 or follow the instructions above to run the SSL test suite.
222 To run an SSL test manually from the command line, the `TEST_CERTS_DIR`
223 environment variable to point to the location of the certs. E.g., from the root
224 OpenSSL directory, do
227 $ TEST_CERTS_DIR=test/certs test/ssl_test test/ssl-tests/01-simple.conf
233 $ TEST_CERTS_DIR=test/certs util/shlib_wrap.sh test/ssl_test \
234 test/ssl-tests/01-simple.conf
237 Some tests also need additional environment variables; for example, Certificate
238 Transparency tests need a `CTLOG_FILE`. See `test/recipes/80-test_ssl_new.t` for
241 Note that the test expectations sometimes depend on the Configure settings. For
242 example, the negotiated protocol depends on the set of available (enabled)
243 protocols: a build with `enable-ssl3` has different test expectations than a
244 build with `no-ssl3`.
246 The Perl test harness automatically generates expected outputs, so users who
247 just run `make test` do not need any extra steps.
249 However, when running a test manually, keep in mind that the repository version
250 of the generated `test/ssl-tests/*.conf` correspond to expected outputs in with
251 the default Configure options. To run `ssl_test` manually from the command line
252 in a build with a different configuration, you may need to generate the right
253 `*.conf` file from the `*.conf.in` input first.