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