SSL_CTX_new.3ossl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "SSL_CTX_NEW 3ossl"
  136. .TH SSL_CTX_NEW 3ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. TLSv1_2_method, TLSv1_2_server_method, TLSv1_2_client_method,
  143. SSL_CTX_new, SSL_CTX_new_ex, SSL_CTX_up_ref, SSLv3_method,
  144. SSLv3_server_method, SSLv3_client_method, TLSv1_method, TLSv1_server_method,
  145. TLSv1_client_method, TLSv1_1_method, TLSv1_1_server_method,
  146. TLSv1_1_client_method, TLS_method, TLS_server_method, TLS_client_method,
  147. SSLv23_method, SSLv23_server_method, SSLv23_client_method, DTLS_method,
  148. DTLS_server_method, DTLS_client_method, DTLSv1_method, DTLSv1_server_method,
  149. DTLSv1_client_method, DTLSv1_2_method, DTLSv1_2_server_method,
  150. DTLSv1_2_client_method
  151. \&\- create a new SSL_CTX object as framework for TLS/SSL or DTLS enabled
  152. functions
  153. .SH "SYNOPSIS"
  154. .IX Header "SYNOPSIS"
  155. .Vb 1
  156. \& #include <openssl/ssl.h>
  157. \&
  158. \& SSL_CTX *SSL_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq,
  159. \& const SSL_METHOD *method);
  160. \& SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
  161. \& int SSL_CTX_up_ref(SSL_CTX *ctx);
  162. \&
  163. \& const SSL_METHOD *TLS_method(void);
  164. \& const SSL_METHOD *TLS_server_method(void);
  165. \& const SSL_METHOD *TLS_client_method(void);
  166. \&
  167. \& const SSL_METHOD *SSLv23_method(void);
  168. \& const SSL_METHOD *SSLv23_server_method(void);
  169. \& const SSL_METHOD *SSLv23_client_method(void);
  170. \&
  171. \& #ifndef OPENSSL_NO_SSL3_METHOD
  172. \& const SSL_METHOD *SSLv3_method(void);
  173. \& const SSL_METHOD *SSLv3_server_method(void);
  174. \& const SSL_METHOD *SSLv3_client_method(void);
  175. \& #endif
  176. \&
  177. \& #ifndef OPENSSL_NO_TLS1_METHOD
  178. \& const SSL_METHOD *TLSv1_method(void);
  179. \& const SSL_METHOD *TLSv1_server_method(void);
  180. \& const SSL_METHOD *TLSv1_client_method(void);
  181. \& #endif
  182. \&
  183. \& #ifndef OPENSSL_NO_TLS1_1_METHOD
  184. \& const SSL_METHOD *TLSv1_1_method(void);
  185. \& const SSL_METHOD *TLSv1_1_server_method(void);
  186. \& const SSL_METHOD *TLSv1_1_client_method(void);
  187. \& #endif
  188. \&
  189. \& #ifndef OPENSSL_NO_TLS1_2_METHOD
  190. \& const SSL_METHOD *TLSv1_2_method(void);
  191. \& const SSL_METHOD *TLSv1_2_server_method(void);
  192. \& const SSL_METHOD *TLSv1_2_client_method(void);
  193. \& #endif
  194. \&
  195. \& const SSL_METHOD *DTLS_method(void);
  196. \& const SSL_METHOD *DTLS_server_method(void);
  197. \& const SSL_METHOD *DTLS_client_method(void);
  198. \&
  199. \& #ifndef OPENSSL_NO_DTLS1_METHOD
  200. \& const SSL_METHOD *DTLSv1_method(void);
  201. \& const SSL_METHOD *DTLSv1_server_method(void);
  202. \& const SSL_METHOD *DTLSv1_client_method(void);
  203. \& #endif
  204. \&
  205. \& #ifndef OPENSSL_NO_DTLS1_2_METHOD
  206. \& const SSL_METHOD *DTLSv1_2_method(void);
  207. \& const SSL_METHOD *DTLSv1_2_server_method(void);
  208. \& const SSL_METHOD *DTLSv1_2_client_method(void);
  209. \& #endif
  210. .Ve
  211. .SH "DESCRIPTION"
  212. .IX Header "DESCRIPTION"
  213. \&\fBSSL_CTX_new_ex()\fR creates a new \fB\s-1SSL_CTX\s0\fR object, which holds various
  214. configuration and data relevant to \s-1SSL/TLS\s0 or \s-1DTLS\s0 session establishment.
  215. These are later inherited by the \fB\s-1SSL\s0\fR object representing an active session.
  216. The \fImethod\fR parameter specifies whether the context will be used for the
  217. client or server side or both \- for details see the \*(L"\s-1NOTES\*(R"\s0 below.
  218. The library context \fIlibctx\fR (see \s-1\fBOSSL_LIB_CTX\s0\fR\|(3)) is used to provide the
  219. cryptographic algorithms needed for the session. Any cryptographic algorithms
  220. that are used by any \fB\s-1SSL\s0\fR objects created from this \fB\s-1SSL_CTX\s0\fR will be fetched
  221. from the \fIlibctx\fR using the property query string \fIpropq\fR (see
  222. \&\*(L"\s-1ALGORITHM FETCHING\*(R"\s0 in \fBcrypto\fR\|(7). Either or both the \fIlibctx\fR or \fIpropq\fR
  223. parameters may be \s-1NULL.\s0
  224. .PP
  225. \&\fBSSL_CTX_new()\fR does the same as \fBSSL_CTX_new_ex()\fR except that the default
  226. library context is used and no property query string is specified.
  227. .PP
  228. An \fB\s-1SSL_CTX\s0\fR object is reference counted. Creating an \fB\s-1SSL_CTX\s0\fR object for the
  229. first time increments the reference count. Freeing the \fB\s-1SSL_CTX\s0\fR (using
  230. SSL_CTX_free) decrements it. When the reference count drops to zero, any memory
  231. or resources allocated to the \fB\s-1SSL_CTX\s0\fR object are freed. \fBSSL_CTX_up_ref()\fR
  232. increments the reference count for an existing \fB\s-1SSL_CTX\s0\fR structure.
  233. .PP
  234. An \fB\s-1SSL_CTX\s0\fR object should not be changed after it is used to create any \fB\s-1SSL\s0\fR
  235. objects or from multiple threads concurrently, since the implementation does not
  236. provide serialization of access for these cases.
  237. .SH "NOTES"
  238. .IX Header "NOTES"
  239. On session establishment, by default, no peer credentials verification is done.
  240. This must be explicitly requested, typically using \fBSSL_CTX_set_verify\fR\|(3).
  241. For verifying peer certificates many options can be set using various functions
  242. such as \fBSSL_CTX_load_verify_locations\fR\|(3) and \fBSSL_CTX_set1_param\fR\|(3).
  243. The \fBX509_VERIFY_PARAM_set_purpose\fR\|(3) function can be used, also in conjunction
  244. with \fBSSL_CTX_get0_param\fR\|(3), to set the intended purpose of the session.
  245. The default is \fBX509_PURPOSE_SSL_SERVER\fR on the client side
  246. and \fBX509_PURPOSE_SSL_CLIENT\fR on the server side.
  247. .PP
  248. The \s-1SSL_CTX\s0 object uses \fImethod\fR as the connection method.
  249. Three method variants are available: a generic method (for either client or
  250. server use), a server-only method, and a client-only method.
  251. .PP
  252. The \fImethod\fR parameter of \fBSSL_CTX_new_ex()\fR and \fBSSL_CTX_new()\fR
  253. can be one of the following:
  254. .IP "\fBTLS_method()\fR, \fBTLS_server_method()\fR, \fBTLS_client_method()\fR" 4
  255. .IX Item "TLS_method(), TLS_server_method(), TLS_client_method()"
  256. These are the general-purpose \fIversion-flexible\fR \s-1SSL/TLS\s0 methods.
  257. The actual protocol version used will be negotiated to the highest version
  258. mutually supported by the client and the server.
  259. The supported protocols are SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3.
  260. Applications should use these methods, and avoid the version-specific
  261. methods described below, which are deprecated.
  262. .IP "\fBSSLv23_method()\fR, \fBSSLv23_server_method()\fR, \fBSSLv23_client_method()\fR" 4
  263. .IX Item "SSLv23_method(), SSLv23_server_method(), SSLv23_client_method()"
  264. These functions do not exist anymore, they have been renamed to
  265. \&\fBTLS_method()\fR, \fBTLS_server_method()\fR and \fBTLS_client_method()\fR respectively.
  266. Currently, the old function calls are renamed to the corresponding new
  267. ones by preprocessor macros, to ensure that existing code which uses the
  268. old function names still compiles. However, using the old function names
  269. is deprecated and new code should call the new functions instead.
  270. .IP "\fBTLSv1_2_method()\fR, \fBTLSv1_2_server_method()\fR, \fBTLSv1_2_client_method()\fR" 4
  271. .IX Item "TLSv1_2_method(), TLSv1_2_server_method(), TLSv1_2_client_method()"
  272. A \s-1TLS/SSL\s0 connection established with these methods will only understand the
  273. TLSv1.2 protocol. These methods are deprecated.
  274. .IP "\fBTLSv1_1_method()\fR, \fBTLSv1_1_server_method()\fR, \fBTLSv1_1_client_method()\fR" 4
  275. .IX Item "TLSv1_1_method(), TLSv1_1_server_method(), TLSv1_1_client_method()"
  276. A \s-1TLS/SSL\s0 connection established with these methods will only understand the
  277. TLSv1.1 protocol. These methods are deprecated.
  278. .IP "\fBTLSv1_method()\fR, \fBTLSv1_server_method()\fR, \fBTLSv1_client_method()\fR" 4
  279. .IX Item "TLSv1_method(), TLSv1_server_method(), TLSv1_client_method()"
  280. A \s-1TLS/SSL\s0 connection established with these methods will only understand the
  281. TLSv1 protocol. These methods are deprecated.
  282. .IP "\fBSSLv3_method()\fR, \fBSSLv3_server_method()\fR, \fBSSLv3_client_method()\fR" 4
  283. .IX Item "SSLv3_method(), SSLv3_server_method(), SSLv3_client_method()"
  284. A \s-1TLS/SSL\s0 connection established with these methods will only understand the
  285. SSLv3 protocol.
  286. The SSLv3 protocol is deprecated and should not be used.
  287. .IP "\fBDTLS_method()\fR, \fBDTLS_server_method()\fR, \fBDTLS_client_method()\fR" 4
  288. .IX Item "DTLS_method(), DTLS_server_method(), DTLS_client_method()"
  289. These are the version-flexible \s-1DTLS\s0 methods.
  290. Currently supported protocols are \s-1DTLS 1.0\s0 and \s-1DTLS 1.2.\s0
  291. .IP "\fBDTLSv1_2_method()\fR, \fBDTLSv1_2_server_method()\fR, \fBDTLSv1_2_client_method()\fR" 4
  292. .IX Item "DTLSv1_2_method(), DTLSv1_2_server_method(), DTLSv1_2_client_method()"
  293. These are the version-specific methods for DTLSv1.2.
  294. These methods are deprecated.
  295. .IP "\fBDTLSv1_method()\fR, \fBDTLSv1_server_method()\fR, \fBDTLSv1_client_method()\fR" 4
  296. .IX Item "DTLSv1_method(), DTLSv1_server_method(), DTLSv1_client_method()"
  297. These are the version-specific methods for DTLSv1.
  298. These methods are deprecated.
  299. .PP
  300. \&\fBSSL_CTX_new()\fR initializes the list of ciphers, the session cache setting, the
  301. callbacks, the keys and certificates and the options to their default values.
  302. .PP
  303. \&\fBTLS_method()\fR, \fBTLS_server_method()\fR, \fBTLS_client_method()\fR, \fBDTLS_method()\fR,
  304. \&\fBDTLS_server_method()\fR and \fBDTLS_client_method()\fR are the \fIversion-flexible\fR
  305. methods.
  306. All other methods only support one specific protocol version.
  307. Use the \fIversion-flexible\fR methods instead of the version specific methods.
  308. .PP
  309. If you want to limit the supported protocols for the version flexible
  310. methods you can use \fBSSL_CTX_set_min_proto_version\fR\|(3),
  311. \&\fBSSL_set_min_proto_version\fR\|(3), \fBSSL_CTX_set_max_proto_version\fR\|(3) and
  312. \&\fBSSL_set_max_proto_version\fR\|(3) functions.
  313. Using these functions it is possible to choose e.g. \fBTLS_server_method()\fR
  314. and be able to negotiate with all possible clients, but to only
  315. allow newer protocols like \s-1TLS 1.0, TLS 1.1, TLS 1.2\s0 or \s-1TLS 1.3.\s0
  316. .PP
  317. The list of protocols available can also be limited using the
  318. \&\fBSSL_OP_NO_SSLv3\fR, \fBSSL_OP_NO_TLSv1\fR, \fBSSL_OP_NO_TLSv1_1\fR,
  319. \&\fBSSL_OP_NO_TLSv1_3\fR, \fBSSL_OP_NO_TLSv1_2\fR and \fBSSL_OP_NO_TLSv1_3\fR
  320. options of the
  321. \&\fBSSL_CTX_set_options\fR\|(3) or \fBSSL_set_options\fR\|(3) functions, but this approach
  322. is not recommended. Clients should avoid creating \*(L"holes\*(R" in the set of
  323. protocols they support. When disabling a protocol, make sure that you also
  324. disable either all previous or all subsequent protocol versions.
  325. In clients, when a protocol version is disabled without disabling \fIall\fR
  326. previous protocol versions, the effect is to also disable all subsequent
  327. protocol versions.
  328. .PP
  329. The SSLv3 protocol is deprecated and should generally not be used.
  330. Applications should typically use \fBSSL_CTX_set_min_proto_version\fR\|(3) to set
  331. the minimum protocol to at least \fB\s-1TLS1_VERSION\s0\fR.
  332. .SH "RETURN VALUES"
  333. .IX Header "RETURN VALUES"
  334. The following return values can occur:
  335. .IP "\s-1NULL\s0" 4
  336. .IX Item "NULL"
  337. The creation of a new \s-1SSL_CTX\s0 object failed. Check the error stack to find out
  338. the reason.
  339. .IP "Pointer to an \s-1SSL_CTX\s0 object" 4
  340. .IX Item "Pointer to an SSL_CTX object"
  341. The return value points to an allocated \s-1SSL_CTX\s0 object.
  342. .Sp
  343. \&\fBSSL_CTX_up_ref()\fR returns 1 for success and 0 for failure.
  344. .SH "SEE ALSO"
  345. .IX Header "SEE ALSO"
  346. \&\fBSSL_CTX_set_options\fR\|(3), \fBSSL_CTX_free\fR\|(3),
  347. \&\fBSSL_CTX_set_verify\fR\|(3), \fBSSL_CTX_set1_param\fR\|(3), \fBSSL_CTX_get0_param\fR\|(3),
  348. \&\fBSSL_connect\fR\|(3), \fBSSL_accept\fR\|(3),
  349. \&\fBSSL_CTX_set_min_proto_version\fR\|(3), \fBssl\fR\|(7), \fBSSL_set_connect_state\fR\|(3)
  350. .SH "HISTORY"
  351. .IX Header "HISTORY"
  352. Support for SSLv2 and the corresponding \fBSSLv2_method()\fR,
  353. \&\fBSSLv2_server_method()\fR and \fBSSLv2_client_method()\fR functions where
  354. removed in OpenSSL 1.1.0.
  355. .PP
  356. \&\fBSSLv23_method()\fR, \fBSSLv23_server_method()\fR and \fBSSLv23_client_method()\fR
  357. were deprecated and the preferred \fBTLS_method()\fR, \fBTLS_server_method()\fR
  358. and \fBTLS_client_method()\fR functions were added in OpenSSL 1.1.0.
  359. .PP
  360. All version-specific methods were deprecated in OpenSSL 1.1.0.
  361. .PP
  362. \&\fBSSL_CTX_new_ex()\fR was added in OpenSSL 3.0.
  363. .SH "COPYRIGHT"
  364. .IX Header "COPYRIGHT"
  365. Copyright 2000\-2023 The OpenSSL Project Authors. All Rights Reserved.
  366. .PP
  367. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  368. this file except in compliance with the License. You can obtain a copy
  369. in the file \s-1LICENSE\s0 in the source distribution or at
  370. <https://www.openssl.org/source/license.html>.