Add support for minimum and maximum protocol version
[openssl.git] / doc / ssl / SSL_CONF_cmd.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CONF_cmd - send configuration command
6
7 =head1 SYNOPSIS
8
9  #include <openssl/ssl.h>
10
11  int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);
12  int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);
13  int SSL_CONF_finish(SSL_CONF_CTX *cctx);
14
15 =head1 DESCRIPTION
16
17 The function SSL_CONF_cmd() performs configuration operation B<cmd> with
18 optional parameter B<value> on B<ctx>. Its purpose is to simplify application
19 configuration of B<SSL_CTX> or B<SSL> structures by providing a common
20 framework for command line options or configuration files.
21
22 SSL_CONF_cmd_value_type() returns the type of value that B<cmd> refers to.
23
24 The function SSL_CONF_finish() must be called after all configuration
25 operations have been completed. It is used to finalise any operations
26 or to process defaults.
27
28 =head1 SUPPORTED COMMAND LINE COMMANDS
29
30 Currently supported B<cmd> names for command lines (i.e. when the
31 flag B<SSL_CONF_CMDLINE> is set) are listed below. Note: all B<cmd> names
32 are case sensitive. Unless otherwise stated commands can be used by
33 both clients and servers and the B<value> parameter is not used. The default
34 prefix for command line commands is B<-> and that is reflected below.
35
36 =over 4
37
38 =item B<-sigalgs>
39
40 This sets the supported signature algorithms for TLS v1.2. For clients this
41 value is used directly for the supported signature algorithms extension. For
42 servers it is used to determine which signature algorithms to support.
43
44 The B<value> argument should be a colon separated list of signature algorithms
45 in order of decreasing preference of the form B<algorithm+hash>. B<algorithm>
46 is one of B<RSA>, B<DSA> or B<ECDSA> and B<hash> is a supported algorithm
47 OID short name such as B<SHA1>, B<SHA224>, B<SHA256>, B<SHA384> of B<SHA512>.
48 Note: algorithm and hash names are case sensitive.
49
50 If this option is not set then all signature algorithms supported by the
51 OpenSSL library are permissible.
52
53 =item B<-client_sigalgs>
54
55 This sets the supported signature algorithms associated with client
56 authentication for TLS v1.2. For servers the value is used in the supported
57 signature algorithms field of a certificate request. For clients it is
58 used to determine which signature algorithm to with the client certificate.
59 If a server does not request a certificate this option has no effect.
60
61 The syntax of B<value> is identical to B<-sigalgs>. If not set then
62 the value set for B<-sigalgs> will be used instead.
63
64 =item B<-curves>
65
66 This sets the supported elliptic curves. For clients the curves are
67 sent using the supported curves extension. For servers it is used
68 to determine which curve to use. This setting affects curves used for both
69 signatures and key exchange, if applicable.
70
71 The B<value> argument is a colon separated list of curves. The curve can be
72 either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name (e.g
73 B<prime256v1>). Curve names are case sensitive.
74
75 =item B<-named_curve>
76
77 This sets the temporary curve used for ephemeral ECDH modes. Only used by
78 servers
79
80 The B<value> argument is a curve name or the special value B<auto> which
81 picks an appropriate curve based on client and server preferences. The curve
82 can be either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name
83 (e.g B<prime256v1>). Curve names are case sensitive.
84
85 =item B<-cipher>
86
87 Sets the cipher suite list to B<value>. Note: syntax checking of B<value> is
88 currently not performed unless a B<SSL> or B<SSL_CTX> structure is
89 associated with B<cctx>.
90
91 =item B<-cert>
92
93 Attempts to use the file B<value> as the certificate for the appropriate
94 context. It currently uses SSL_CTX_use_certificate_chain_file() if an B<SSL_CTX>
95 structure is set or SSL_use_certificate_file() with filetype PEM if an B<SSL>
96 structure is set. This option is only supported if certificate operations
97 are permitted.
98
99 =item B<-key>
100
101 Attempts to use the file B<value> as the private key for the appropriate
102 context. This option is only supported if certificate operations
103 are permitted. Note: if no B<-key> option is set then a private key is
104 not loaded unless the flag B<SSL_CONF_FLAG_REQUIRE_PRIVATE> is set.
105
106 =item B<-dhparam>
107
108 Attempts to use the file B<value> as the set of temporary DH parameters for
109 the appropriate context. This option is only supported if certificate
110 operations are permitted.
111
112 =item B<-min_protocol>, B<-max_protocol>
113
114 Sets the minimum and maximum supported protocol.
115 Currently supported protocol values are B<SSLv3>, B<TLSv1>, B<TLSv1.1>, B<TLSv1.2>, B<DTLSv1> and B<DTLSv1.2>.
116
117 =item B<-no_ssl3>, B<-no_tls1>, B<-no_tls1_1>, B<-no_tls1_2>
118
119 Disables protocol support for SSLv3, TLS 1.0, TLS 1.1 or TLS 1.2
120 by setting the corresponding options B<SSL_OP_NO_SSL3>,
121 B<SSL_OP_NO_TLS1>, B<SSL_OP_NO_TLS1_1> and B<SSL_OP_NO_TLS1_2> respectively.
122
123 =item B<-bugs>
124
125 Various bug workarounds are set, same as setting B<SSL_OP_ALL>.
126
127 =item B<-no_comp>
128
129 Disables support for SSL/TLS compression, same as setting B<SSL_OP_NO_COMPRESS>.
130
131 =item B<-no_ticket>
132
133 Disables support for session tickets, same as setting B<SSL_OP_NO_TICKET>.
134
135 =item B<-serverpref>
136
137 Use server and not client preference order when determining which cipher suite,
138 signature algorithm or elliptic curve to use for an incoming connection.
139 Equivalent to B<SSL_OP_CIPHER_SERVER_PREFERENCE>. Only used by servers.
140
141 =item B<-no_resumption_on_reneg>
142
143 set SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION flag. Only used by servers.
144
145 =item B<-legacyrenegotiation>
146
147 permits the use of unsafe legacy renegotiation. Equivalent to setting
148 B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION>.
149
150 =item B<-legacy_server_connect>, B<-no_legacy_server_connect>
151
152 permits or prohibits the use of unsafe legacy renegotiation for OpenSSL
153 clients only. Equivalent to setting or clearing B<SSL_OP_LEGACY_SERVER_CONNECT>.
154 Set by default.
155
156 =item B<-strict>
157
158 enables strict mode protocol handling. Equivalent to setting
159 B<SSL_CERT_FLAG_TLS_STRICT>.
160
161 =item B<-debug_broken_protocol>
162
163 disables various checks and permits several kinds of broken protocol behaviour
164 for testing purposes: it should B<NEVER> be used in anything other than a test
165 environment. Only supported if OpenSSL is configured with
166 B<-DOPENSSL_SSL_DEBUG_BROKEN_PROTOCOL>.
167
168 =back
169
170 =head1 SUPPORTED CONFIGURATION FILE COMMANDS
171
172 Currently supported B<cmd> names for configuration files (i.e. when the
173 flag B<SSL_CONF_FLAG_FILE> is set) are listed below. All configuration file
174 B<cmd> names are case insensitive so B<signaturealgorithms> is recognised
175 as well as B<SignatureAlgorithms>. Unless otherwise stated the B<value> names
176 are also case insensitive.
177
178 Note: the command prefix (if set) alters the recognised B<cmd> values.
179
180 =over 4
181
182 =item B<CipherString>
183
184 Sets the cipher suite list to B<value>. Note: syntax checking of B<value> is
185 currently not performed unless an B<SSL> or B<SSL_CTX> structure is
186 associated with B<cctx>.
187
188 =item B<Certificate>
189
190 Attempts to use the file B<value> as the certificate for the appropriate
191 context. It currently uses SSL_CTX_use_certificate_chain_file() if an B<SSL_CTX>
192 structure is set or SSL_use_certificate_file() with filetype PEM if an B<SSL>
193 structure is set. This option is only supported if certificate operations
194 are permitted.
195
196 =item B<PrivateKey>
197
198 Attempts to use the file B<value> as the private key for the appropriate
199 context. This option is only supported if certificate operations
200 are permitted. Note: if no B<PrivateKey> option is set then a private key is
201 not loaded unless the B<SSL_CONF_FLAG_REQUIRE_PRIVATE> is set.
202
203 =item B<ChainCAFile>, B<ChainCAPath>, B<VerifyCAFile>, B<VerifyCAPath>
204
205 These options indicate a file or directory used for building certificate
206 chains or verifying certificate chains. These options are only supported
207 if certificate operations are permitted.
208
209 =item B<ServerInfoFile>
210
211 Attempts to use the file B<value> in the "serverinfo" extension using the
212 function SSL_CTX_use_serverinfo_file.
213
214 =item B<DHParameters>
215
216 Attempts to use the file B<value> as the set of temporary DH parameters for
217 the appropriate context. This option is only supported if certificate
218 operations are permitted.
219
220 =item B<SignatureAlgorithms>
221
222 This sets the supported signature algorithms for TLS v1.2. For clients this
223 value is used directly for the supported signature algorithms extension. For
224 servers it is used to determine which signature algorithms to support.
225
226 The B<value> argument should be a colon separated list of signature algorithms
227 in order of decreasing preference of the form B<algorithm+hash>. B<algorithm>
228 is one of B<RSA>, B<DSA> or B<ECDSA> and B<hash> is a supported algorithm
229 OID short name such as B<SHA1>, B<SHA224>, B<SHA256>, B<SHA384> of B<SHA512>.
230 Note: algorithm and hash names are case sensitive.
231
232 If this option is not set then all signature algorithms supported by the
233 OpenSSL library are permissible.
234
235 =item B<ClientSignatureAlgorithms>
236
237 This sets the supported signature algorithms associated with client
238 authentication for TLS v1.2. For servers the value is used in the supported
239 signature algorithms field of a certificate request. For clients it is
240 used to determine which signature algorithm to with the client certificate.
241
242 The syntax of B<value> is identical to B<SignatureAlgorithms>. If not set then
243 the value set for B<SignatureAlgorithms> will be used instead.
244
245 =item B<Curves>
246
247 This sets the supported elliptic curves. For clients the curves are
248 sent using the supported curves extension. For servers it is used
249 to determine which curve to use. This setting affects curves used for both
250 signatures and key exchange, if applicable.
251
252 The B<value> argument is a colon separated list of curves. The curve can be
253 either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name (e.g
254 B<prime256v1>). Curve names are case sensitive.
255
256 =item B<ECDHParameters>
257
258 This sets the temporary curve used for ephemeral ECDH modes. Only used by
259 servers
260
261 The B<value> argument is a curve name or the special value B<Automatic> which
262 picks an appropriate curve based on client and server preferences. The curve
263 can be either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name
264 (e.g B<prime256v1>). Curve names are case sensitive.
265
266 =item B<MinProtocol>
267
268 This sets the minimum supported SSL, TLS or DTLS version.
269
270 Currently supported protocol values are B<SSLv3>, B<TLSv1>, B<TLSv1.1>, B<TLSv1.2>, B<DTLSv1> and B<DTLSv1.2>.
271
272 =item B<MaxProtocol>
273
274 This sets the maximum supported SSL, TLS or DTLS version.
275
276 Currently supported protocol values are B<SSLv3>, B<TLSv1>, B<TLSv1.1>, B<TLSv1.2>, B<DTLSv1> and B<DTLSv1.2>.
277
278 =item B<Protocol>
279
280 This can be used to enable or disable certain versions of the SSL, TLS or DTLS protocol.
281
282 The B<value> argument is a comma separated list of supported protocols to enable or disable.
283 If a protocol is preceded by B<-> that version is disabled.
284
285 All protocol versions are enabled by default.
286 You need to disable at least 1 protocol version for this setting have any effect.
287 Only enabling some protocol versions does not disable the other protocol versions.
288
289 Currently supported protocol values are B<SSLv3>, B<TLSv1>, B<TLSv1.1>, B<TLSv1.2>, B<DTLSv1> and B<DTLSv1.2>.
290 The special value B<ALL> refers to all supported versions.
291
292 This can't enable protocols that are disabled using B<MinProtocol> or B<MaxProtocol>, but can disable protocols that are still allowed by them.
293
294 The B<Protocol> command is fragile and deprecated; do not use it.
295 Use B<MinProtocol> and B<MaxProtocol> instead.
296 If you do use B<Protocol>, make sure that the resulting range of enabled protocols has no "holes", e.g. if TLS 1.0 and TLS 1.2 are both enabled, make sure to also leave TLS 1.1 enabled.
297
298 =item B<Options>
299
300 The B<value> argument is a comma separated list of various flags to set.
301 If a flag string is preceded B<-> it is disabled. See the
302 B<SSL_CTX_set_options> function for more details of individual options.
303
304 Each option is listed below. Where an operation is enabled by default
305 the B<-flag> syntax is needed to disable it.
306
307 B<SessionTicket>: session ticket support, enabled by default. Inverse of
308 B<SSL_OP_NO_TICKET>: that is B<-SessionTicket> is the same as setting
309 B<SSL_OP_NO_TICKET>.
310
311 B<Compression>: SSL/TLS compression support, enabled by default. Inverse
312 of B<SSL_OP_NO_COMPRESSION>.
313
314 B<EmptyFragments>: use empty fragments as a countermeasure against a
315 SSL 3.0/TLS 1.0 protocol vulnerability affecting CBC ciphers. It
316 is set by default. Inverse of B<SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS>.
317
318 B<Bugs>: enable various bug workarounds. Same as B<SSL_OP_ALL>.
319
320 B<DHSingle>: enable single use DH keys, set by default. Inverse of
321 B<SSL_OP_DH_SINGLE>. Only used by servers.
322
323 B<ECDHSingle> enable single use ECDH keys, set by default. Inverse of
324 B<SSL_OP_ECDH_SINGLE>. Only used by servers.
325
326 B<ServerPreference> use server and not client preference order when
327 determining which cipher suite, signature algorithm or elliptic curve
328 to use for an incoming connection.  Equivalent to
329 B<SSL_OP_CIPHER_SERVER_PREFERENCE>. Only used by servers.
330
331 B<NoResumptionOnRenegotiation> set
332 B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> flag. Only used by servers.
333
334 B<UnsafeLegacyRenegotiation> permits the use of unsafe legacy renegotiation.
335 Equivalent to B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION>.
336
337 B<UnsafeLegacyServerConnect> permits the use of unsafe legacy renegotiation
338 for OpenSSL clients only. Equivalent to B<SSL_OP_LEGACY_SERVER_CONNECT>.
339 Set by default.
340
341 =item B<VerifyMode>
342
343 The B<value> argument is a comma separated list of flags to set.
344
345 B<Peer> enables peer verification: for clients only.
346
347 B<Request> requests but does not require a certificate from the client.
348 Servers only.
349
350 B<Require> requests and requires a certificate from the client: an error
351 occurs if the client does not present a certificate. Servers only.
352
353 B<Once> requests a certificate from a client only on the initial connection:
354 not when renegotiating. Servers only.
355
356 =item B<ClientCAFile>, B<ClientCAPath>
357
358 A file or directory of certificates in PEM format whose names are used as the
359 set of acceptable names for client CAs. Servers only. This option is only
360 supported if certificate operations are permitted.
361
362 =back
363
364 =head1 SUPPORTED COMMAND TYPES
365
366 The function SSL_CONF_cmd_value_type() currently returns one of the following
367 types:
368
369 =over 4
370
371 =item B<SSL_CONF_TYPE_UNKNOWN>
372
373 The B<cmd> string is unrecognised, this return value can be use to flag
374 syntax errors.
375
376 =item B<SSL_CONF_TYPE_STRING>
377
378 The value is a string without any specific structure.
379
380 =item B<SSL_CONF_TYPE_FILE>
381
382 The value is a file name.
383
384 =item B<SSL_CONF_TYPE_DIR>
385
386 The value is a directory name.
387
388 =item B<SSL_CONF_TYPE_NONE>
389
390 The value string is not used e.g. a command line option which doesn't take an
391 argument.
392
393 =back
394
395 =head1 NOTES
396
397 The order of operations is significant. This can be used to set either defaults
398 or values which cannot be overridden. For example if an application calls:
399
400  SSL_CONF_cmd(ctx, "Protocol", "-SSLv3");
401  SSL_CONF_cmd(ctx, userparam, uservalue);
402
403 it will disable SSLv3 support by default but the user can override it. If
404 however the call sequence is:
405
406  SSL_CONF_cmd(ctx, userparam, uservalue);
407  SSL_CONF_cmd(ctx, "Protocol", "-SSLv3");
408
409 SSLv3 is B<always> disabled and attempt to override this by the user are
410 ignored.
411
412 By checking the return code of SSL_CTX_cmd() it is possible to query if a
413 given B<cmd> is recognised, this is useful is SSL_CTX_cmd() values are
414 mixed with additional application specific operations.
415
416 For example an application might call SSL_CTX_cmd() and if it returns
417 -2 (unrecognised command) continue with processing of application specific
418 commands.
419
420 Applications can also use SSL_CTX_cmd() to process command lines though the
421 utility function SSL_CTX_cmd_argv() is normally used instead. One way
422 to do this is to set the prefix to an appropriate value using
423 SSL_CONF_CTX_set1_prefix(), pass the current argument to B<cmd> and the
424 following argument to B<value> (which may be NULL).
425
426 In this case if the return value is positive then it is used to skip that
427 number of arguments as they have been processed by SSL_CTX_cmd(). If -2 is
428 returned then B<cmd> is not recognised and application specific arguments
429 can be checked instead. If -3 is returned a required argument is missing
430 and an error is indicated. If 0 is returned some other error occurred and
431 this can be reported back to the user.
432
433 The function SSL_CONF_cmd_value_type() can be used by applications to
434 check for the existence of a command or to perform additional syntax
435 checking or translation of the command value. For example if the return
436 value is B<SSL_CONF_TYPE_FILE> an application could translate a relative
437 pathname to an absolute pathname.
438
439 =head1 EXAMPLES
440
441 Set supported signature algorithms:
442
443  SSL_CONF_cmd(ctx, "SignatureAlgorithms", "ECDSA+SHA256:RSA+SHA256:DSA+SHA256");
444
445 There are various ways to select the supported procotols.
446
447 This set the minimum protocol version to TLSv1, and so disables SSLv3.
448 This is the recommended way to disable protocols.
449
450  SSL_CONF_cmd(ctx, "MinProtocol", "TLSv1");
451
452 The following also disables SSLv3:
453
454  SSL_CONF_cmd(ctx, "Protocol", "-SSLv3");
455
456 The following will first enable all protocols, and then disable SSLv3.
457 If nothing was disabled before it has the same effect as "-SSLv3", but if things were disables it will first enable them again before disabling SSLv3.
458
459  SSL_CONF_cmd(ctx, "Protocol", "ALL,-SSLv3");
460
461 Only enable TLSv1.2:
462
463  SSL_CONF_cmd(ctx, "MinProtocol", "TLSv1.2");
464  SSL_CONF_cmd(ctx, "MaxProtocol", "TLSv1.2");
465
466 This also only enables TLSv1.2:
467
468  SSL_CONF_cmd(ctx, "Protocol", "-ALL,TLSv1.2");
469
470 Disable TLS session tickets:
471
472  SSL_CONF_cmd(ctx, "Options", "-SessionTicket");
473
474 Set supported curves to P-256, P-384:
475
476  SSL_CONF_cmd(ctx, "Curves", "P-256:P-384");
477
478 Set automatic support for any elliptic curve for key exchange:
479
480  SSL_CONF_cmd(ctx, "ECDHParameters", "Automatic");
481
482 =head1 RETURN VALUES
483
484 SSL_CONF_cmd() returns 1 if the value of B<cmd> is recognised and B<value> is
485 B<NOT> used and 2 if both B<cmd> and B<value> are used. In other words it
486 returns the number of arguments processed. This is useful when processing
487 command lines.
488
489 A return value of -2 means B<cmd> is not recognised.
490
491 A return value of -3 means B<cmd> is recognised and the command requires a
492 value but B<value> is NULL.
493
494 A return code of 0 indicates that both B<cmd> and B<value> are valid but an
495 error occurred attempting to perform the operation: for example due to an
496 error in the syntax of B<value> in this case the error queue may provide
497 additional information.
498
499 SSL_CONF_finish() returns 1 for success and 0 for failure.
500
501 =head1 SEE ALSO
502
503 L<SSL_CONF_CTX_new(3)>,
504 L<SSL_CONF_CTX_set_flags(3)>,
505 L<SSL_CONF_CTX_set1_prefix(3)>,
506 L<SSL_CONF_CTX_set_ssl_ctx(3)>,
507 L<SSL_CONF_cmd_argv(3)>
508
509 =head1 HISTORY
510
511 SSL_CONF_cmd() was first added to OpenSSL 1.0.2
512
513 B<SSL_OP_NO_SSL2> doesn't have effect anymore since 1.1.0 but the define is kept
514 for backward compatibility.
515
516 B<SSL_CONF_TYPE_NONE> was first added to OpenSSL 1.1.0. In earlier versions of
517 OpenSSL passing a command which didn't take an argument would return
518 B<SSL_CONF_TYPE_UNKNOWN>.
519
520 B<MinProtocol> and B<MaxProtocol> where added in OpenSSL 1.1.0.
521
522 =cut