SSL_CONF_cmd.pod 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. =pod
  2. =head1 NAME
  3. SSL_CONF_cmd - send configuration command
  4. =head1 SYNOPSIS
  5. #include <openssl/ssl.h>
  6. int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);
  7. int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);
  8. int SSL_CONF_finish(SSL_CONF_CTX *cctx);
  9. =head1 DESCRIPTION
  10. The function SSL_CONF_cmd() performs configuration operation B<cmd> with
  11. optional parameter B<value> on B<ctx>. Its purpose is to simplify application
  12. configuration of B<SSL_CTX> or B<SSL> structures by providing a common
  13. framework for command line options or configuration files.
  14. SSL_CONF_cmd_value_type() returns the type of value that B<cmd> refers to.
  15. The function SSL_CONF_finish() must be called after all configuration
  16. operations have been completed. It is used to finalise any operations
  17. or to process defaults.
  18. =head1 SUPPORTED COMMAND LINE COMMANDS
  19. Currently supported B<cmd> names for command lines (i.e. when the
  20. flag B<SSL_CONF_CMDLINE> is set) are listed below. Note: all B<cmd> names
  21. are case sensitive. Unless otherwise stated commands can be used by
  22. both clients and servers and the B<value> parameter is not used. The default
  23. prefix for command line commands is B<-> and that is reflected below.
  24. =over 4
  25. =item B<-sigalgs>
  26. This sets the supported signature algorithms for TLS v1.2. For clients this
  27. value is used directly for the supported signature algorithms extension. For
  28. servers it is used to determine which signature algorithms to support.
  29. The B<value> argument should be a colon separated list of signature algorithms
  30. in order of decreasing preference of the form B<algorithm+hash>. B<algorithm>
  31. is one of B<RSA>, B<DSA> or B<ECDSA> and B<hash> is a supported algorithm
  32. OID short name such as B<SHA1>, B<SHA224>, B<SHA256>, B<SHA384> of B<SHA512>.
  33. Note: algorithm and hash names are case sensitive.
  34. If this option is not set then all signature algorithms supported by the
  35. OpenSSL library are permissible.
  36. =item B<-client_sigalgs>
  37. This sets the supported signature algorithms associated with client
  38. authentication for TLS v1.2. For servers the value is used in the supported
  39. signature algorithms field of a certificate request. For clients it is
  40. used to determine which signature algorithm to with the client certificate.
  41. If a server does not request a certificate this option has no effect.
  42. The syntax of B<value> is identical to B<-sigalgs>. If not set then
  43. the value set for B<-sigalgs> will be used instead.
  44. =item B<-curves>
  45. This sets the supported elliptic curves. For clients the curves are
  46. sent using the supported curves extension. For servers it is used
  47. to determine which curve to use. This setting affects curves used for both
  48. signatures and key exchange, if applicable.
  49. The B<value> argument is a colon separated list of curves. The curve can be
  50. either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name (e.g
  51. B<prime256v1>). Curve names are case sensitive.
  52. =item B<-named_curve>
  53. This sets the temporary curve used for ephemeral ECDH modes. Only used by
  54. servers
  55. The B<value> argument is a curve name or the special value B<auto> which
  56. picks an appropriate curve based on client and server preferences. The curve
  57. can be either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name
  58. (e.g B<prime256v1>). Curve names are case sensitive.
  59. =item B<-cipher>
  60. Sets the cipher suite list to B<value>. Note: syntax checking of B<value> is
  61. currently not performed unless a B<SSL> or B<SSL_CTX> structure is
  62. associated with B<cctx>.
  63. =item B<-cert>
  64. Attempts to use the file B<value> as the certificate for the appropriate
  65. context. It currently uses SSL_CTX_use_certificate_chain_file() if an B<SSL_CTX>
  66. structure is set or SSL_use_certificate_file() with filetype PEM if an B<SSL>
  67. structure is set. This option is only supported if certificate operations
  68. are permitted.
  69. =item B<-key>
  70. Attempts to use the file B<value> as the private key for the appropriate
  71. context. This option is only supported if certificate operations
  72. are permitted. Note: if no B<-key> option is set then a private key is
  73. not loaded: it does not currently use the B<-cert> file.
  74. =item B<-dhparam>
  75. Attempts to use the file B<value> as the set of temporary DH parameters for
  76. the appropriate context. This option is only supported if certificate
  77. operations are permitted.
  78. =item B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>, B<-no_tls1_1>, B<-no_tls1_2>
  79. Disables protocol support for SSLv2, SSLv3, TLSv1.0, TLSv1.1 or TLSv1.2
  80. by setting the corresponding options B<SSL_OP_NO_SSLv2>, B<SSL_OP_NO_SSLv3>,
  81. B<SSL_OP_NO_TLSv1>, B<SSL_OP_NO_TLSv1_1> and B<SSL_OP_NO_TLSv1_2> respectively.
  82. =item B<-bugs>
  83. Various bug workarounds are set, same as setting B<SSL_OP_ALL>.
  84. =item B<-no_comp>
  85. Disables support for SSL/TLS compression, same as setting B<SSL_OP_NO_COMPRESS>.
  86. =item B<-no_ticket>
  87. Disables support for session tickets, same as setting B<SSL_OP_NO_TICKET>.
  88. =item B<-serverpref>
  89. Use server and not client preference order when determining which cipher suite,
  90. signature algorithm or elliptic curve to use for an incoming connection.
  91. Equivalent to B<SSL_OP_CIPHER_SERVER_PREFERENCE>. Only used by servers.
  92. =item B<-no_resumption_on_reneg>
  93. set SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION flag. Only used by servers.
  94. =item B<-legacyrenegotiation>
  95. permits the use of unsafe legacy renegotiation. Equivalent to setting
  96. B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION>.
  97. =item B<-legacy_server_connect>, B<-no_legacy_server_connect>
  98. permits or prohibits the use of unsafe legacy renegotiation for OpenSSL
  99. clients only. Equivalent to setting or clearing B<SSL_OP_LEGACY_SERVER_CONNECT>.
  100. Set by default.
  101. =item B<-strict>
  102. enables strict mode protocol handling. Equivalent to setting
  103. B<SSL_CERT_FLAG_TLS_STRICT>.
  104. =item B<-debug_broken_protocol>
  105. disables various checks and permits several kinds of broken protocol behaviour
  106. for testing purposes: it should B<NEVER> be used in anything other than a test
  107. environment. Only supported if OpenSSL is configured with
  108. B<-DOPENSSL_SSL_DEBUG_BROKEN_PROTOCOL>.
  109. =back
  110. =head1 SUPPORTED CONFIGURATION FILE COMMANDS
  111. Currently supported B<cmd> names for configuration files (i.e. when the
  112. flag B<SSL_CONF_FLAG_FILE> is set) are listed below. All configuration file
  113. B<cmd> names and are case insensitive so B<signaturealgorithms> is recognised
  114. as well as B<SignatureAlgorithms>. Unless otherwise stated the B<value> names
  115. are also case insensitive.
  116. Note: the command prefix (if set) alters the recognised B<cmd> values.
  117. =over 4
  118. =item B<CipherString>
  119. Sets the cipher suite list to B<value>. Note: syntax checking of B<value> is
  120. currently not performed unless an B<SSL> or B<SSL_CTX> structure is
  121. associated with B<cctx>.
  122. =item B<Certificate>
  123. Attempts to use the file B<value> as the certificate for the appropriate
  124. context. It currently uses SSL_CTX_use_certificate_chain_file() if an B<SSL_CTX>
  125. structure is set or SSL_use_certificate_file() with filetype PEM if an B<SSL>
  126. structure is set. This option is only supported if certificate operations
  127. are permitted.
  128. =item B<PrivateKey>
  129. Attempts to use the file B<value> as the private key for the appropriate
  130. context. This option is only supported if certificate operations
  131. are permitted. Note: if no B<-key> option is set then a private key is
  132. not loaded: it does not currently use the B<Certificate> file.
  133. =item B<ServerInfoFile>
  134. Attempts to use the file B<value> in the "serverinfo" extension using the
  135. function SSL_CTX_use_serverinfo_file.
  136. =item B<DHParameters>
  137. Attempts to use the file B<value> as the set of temporary DH parameters for
  138. the appropriate context. This option is only supported if certificate
  139. operations are permitted.
  140. =item B<SignatureAlgorithms>
  141. This sets the supported signature algorithms for TLS v1.2. For clients this
  142. value is used directly for the supported signature algorithms extension. For
  143. servers it is used to determine which signature algorithms to support.
  144. The B<value> argument should be a colon separated list of signature algorithms
  145. in order of decreasing preference of the form B<algorithm+hash>. B<algorithm>
  146. is one of B<RSA>, B<DSA> or B<ECDSA> and B<hash> is a supported algorithm
  147. OID short name such as B<SHA1>, B<SHA224>, B<SHA256>, B<SHA384> of B<SHA512>.
  148. Note: algorithm and hash names are case sensitive.
  149. If this option is not set then all signature algorithms supported by the
  150. OpenSSL library are permissible.
  151. =item B<ClientSignatureAlgorithms>
  152. This sets the supported signature algorithms associated with client
  153. authentication for TLS v1.2. For servers the value is used in the supported
  154. signature algorithms field of a certificate request. For clients it is
  155. used to determine which signature algorithm to with the client certificate.
  156. The syntax of B<value> is identical to B<SignatureAlgorithms>. If not set then
  157. the value set for B<SignatureAlgorithms> will be used instead.
  158. =item B<Curves>
  159. This sets the supported elliptic curves. For clients the curves are
  160. sent using the supported curves extension. For servers it is used
  161. to determine which curve to use. This setting affects curves used for both
  162. signatures and key exchange, if applicable.
  163. The B<value> argument is a colon separated list of curves. The curve can be
  164. either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name (e.g
  165. B<prime256v1>). Curve names are case sensitive.
  166. =item B<ECDHParameters>
  167. This sets the temporary curve used for ephemeral ECDH modes. Only used by
  168. servers
  169. The B<value> argument is a curve name or the special value B<Automatic> which
  170. picks an appropriate curve based on client and server preferences. The curve
  171. can be either the B<NIST> name (e.g. B<P-256>) or an OpenSSL OID name
  172. (e.g B<prime256v1>). Curve names are case sensitive.
  173. =item B<Protocol>
  174. The supported versions of the SSL or TLS protocol.
  175. The B<value> argument is a comma separated list of supported protocols to
  176. enable or disable. If an protocol is preceded by B<-> that version is disabled.
  177. Currently supported protocol values are B<SSLv2>, B<SSLv3>, B<TLSv1>,
  178. B<TLSv1.1> and B<TLSv1.2>.
  179. All protocol versions other than B<SSLv2> are enabled by default.
  180. To avoid inadvertent enabling of B<SSLv2>, when SSLv2 is disabled, it is not
  181. possible to enable it via the B<Protocol> command.
  182. =item B<Options>
  183. The B<value> argument is a comma separated list of various flags to set.
  184. If a flag string is preceded B<-> it is disabled. See the
  185. B<SSL_CTX_set_options> function for more details of individual options.
  186. Each option is listed below. Where an operation is enabled by default
  187. the B<-flag> syntax is needed to disable it.
  188. B<SessionTicket>: session ticket support, enabled by default. Inverse of
  189. B<SSL_OP_NO_TICKET>: that is B<-SessionTicket> is the same as setting
  190. B<SSL_OP_NO_TICKET>.
  191. B<Compression>: SSL/TLS compression support, enabled by default. Inverse
  192. of B<SSL_OP_NO_COMPRESSION>.
  193. B<EmptyFragments>: use empty fragments as a countermeasure against a
  194. SSL 3.0/TLS 1.0 protocol vulnerability affecting CBC ciphers. It
  195. is set by default. Inverse of B<SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS>.
  196. B<Bugs>: enable various bug workarounds. Same as B<SSL_OP_ALL>.
  197. B<DHSingle>: enable single use DH keys, set by default. Inverse of
  198. B<SSL_OP_DH_SINGLE>. Only used by servers.
  199. B<ECDHSingle> enable single use ECDH keys, set by default. Inverse of
  200. B<SSL_OP_ECDH_SINGLE>. Only used by servers.
  201. B<ServerPreference> use server and not client preference order when
  202. determining which cipher suite, signature algorithm or elliptic curve
  203. to use for an incoming connection. Equivalent to
  204. B<SSL_OP_CIPHER_SERVER_PREFERENCE>. Only used by servers.
  205. B<NoResumptionOnRenegotiation> set
  206. B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> flag. Only used by servers.
  207. B<UnsafeLegacyRenegotiation> permits the use of unsafe legacy renegotiation.
  208. Equivalent to B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION>.
  209. B<UnsafeLegacyServerConnect> permits the use of unsafe legacy renegotiation
  210. for OpenSSL clients only. Equivalent to B<SSL_OP_LEGACY_SERVER_CONNECT>.
  211. Set by default.
  212. =back
  213. =head1 SUPPORTED COMMAND TYPES
  214. The function SSL_CONF_cmd_value_type() currently returns one of the following
  215. types:
  216. =over 4
  217. =item B<SSL_CONF_TYPE_UNKNOWN>
  218. The B<cmd> string is unrecognised, this return value can be use to flag
  219. syntax errors.
  220. =item B<SSL_CONF_TYPE_STRING>
  221. The value is a string without any specific structure.
  222. =item B<SSL_CONF_TYPE_FILE>
  223. The value is a file name.
  224. =item B<SSL_CONF_TYPE_DIR>
  225. The value is a directory name.
  226. =back
  227. =head1 NOTES
  228. The order of operations is significant. This can be used to set either defaults
  229. or values which cannot be overridden. For example if an application calls:
  230. SSL_CONF_cmd(ctx, "Protocol", "-SSLv3");
  231. SSL_CONF_cmd(ctx, userparam, uservalue);
  232. it will disable SSLv3 support by default but the user can override it. If
  233. however the call sequence is:
  234. SSL_CONF_cmd(ctx, userparam, uservalue);
  235. SSL_CONF_cmd(ctx, "Protocol", "-SSLv3");
  236. then SSLv3 is B<always> disabled and attempt to override this by the user are
  237. ignored.
  238. By checking the return code of SSL_CTX_cmd() it is possible to query if a
  239. given B<cmd> is recognised, this is useful is SSL_CTX_cmd() values are
  240. mixed with additional application specific operations.
  241. For example an application might call SSL_CTX_cmd() and if it returns
  242. -2 (unrecognised command) continue with processing of application specific
  243. commands.
  244. Applications can also use SSL_CTX_cmd() to process command lines though the
  245. utility function SSL_CTX_cmd_argv() is normally used instead. One way
  246. to do this is to set the prefix to an appropriate value using
  247. SSL_CONF_CTX_set1_prefix(), pass the current argument to B<cmd> and the
  248. following argument to B<value> (which may be NULL).
  249. In this case if the return value is positive then it is used to skip that
  250. number of arguments as they have been processed by SSL_CTX_cmd(). If -2 is
  251. returned then B<cmd> is not recognised and application specific arguments
  252. can be checked instead. If -3 is returned a required argument is missing
  253. and an error is indicated. If 0 is returned some other error occurred and
  254. this can be reported back to the user.
  255. The function SSL_CONF_cmd_value_type() can be used by applications to
  256. check for the existence of a command or to perform additional syntax
  257. checking or translation of the command value. For example if the return
  258. value is B<SSL_CONF_TYPE_FILE> an application could translate a relative
  259. pathname to an absolute pathname.
  260. =head1 EXAMPLES
  261. Set supported signature algorithms:
  262. SSL_CONF_cmd(ctx, "SignatureAlgorithms", "ECDSA+SHA256:RSA+SHA256:DSA+SHA256");
  263. Enable all protocols except SSLv3 and SSLv2:
  264. SSL_CONF_cmd(ctx, "Protocol", "ALL,-SSLv3,-SSLv2");
  265. Only enable TLSv1.2:
  266. SSL_CONF_cmd(ctx, "Protocol", "-ALL,TLSv1.2");
  267. Disable TLS session tickets:
  268. SSL_CONF_cmd(ctx, "Options", "-SessionTicket");
  269. Set supported curves to P-256, P-384:
  270. SSL_CONF_cmd(ctx, "Curves", "P-256:P-384");
  271. Set automatic support for any elliptic curve for key exchange:
  272. SSL_CONF_cmd(ctx, "ECDHParameters", "Automatic");
  273. =head1 RETURN VALUES
  274. SSL_CONF_cmd() returns 1 if the value of B<cmd> is recognised and B<value> is
  275. B<NOT> used and 2 if both B<cmd> and B<value> are used. In other words it
  276. returns the number of arguments processed. This is useful when processing
  277. command lines.
  278. A return value of -2 means B<cmd> is not recognised.
  279. A return value of -3 means B<cmd> is recognised and the command requires a
  280. value but B<value> is NULL.
  281. A return code of 0 indicates that both B<cmd> and B<value> are valid but an
  282. error occurred attempting to perform the operation: for example due to an
  283. error in the syntax of B<value> in this case the error queue may provide
  284. additional information.
  285. SSL_CONF_finish() returns 1 for success and 0 for failure.
  286. =head1 SEE ALSO
  287. L<SSL_CONF_CTX_new(3)|SSL_CONF_CTX_new(3)>,
  288. L<SSL_CONF_CTX_set_flags(3)|SSL_CONF_CTX_set_flags(3)>,
  289. L<SSL_CONF_CTX_set1_prefix(3)|SSL_CONF_CTX_set1_prefix(3)>,
  290. L<SSL_CONF_CTX_set_ssl_ctx(3)|SSL_CONF_CTX_set_ssl_ctx(3)>,
  291. L<SSL_CONF_cmd_argv(3)|SSL_CONF_cmd_argv(3)>
  292. =head1 HISTORY
  293. SSL_CONF_cmd() was first added to OpenSSL 1.0.2
  294. =cut