SSL_CTX_new.pod 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. =pod
  2. =head1 NAME
  3. TLSv1_2_method, TLSv1_2_server_method, TLSv1_2_client_method,
  4. SSL_CTX_new, SSL_CTX_up_ref, SSLv3_method, SSLv3_server_method,
  5. SSLv3_client_method, TLSv1_method, TLSv1_server_method, TLSv1_client_method,
  6. TLSv1_1_method, TLSv1_1_server_method, TLSv1_1_client_method, TLS_method,
  7. TLS_server_method, TLS_client_method, SSLv23_method, SSLv23_server_method,
  8. SSLv23_client_method, DTLS_method, DTLS_server_method, DTLS_client_method,
  9. DTLSv1_method, DTLSv1_server_method, DTLSv1_client_method,
  10. DTLSv1_2_method, DTLSv1_2_server_method, DTLSv1_2_client_method
  11. - create a new SSL_CTX object as framework for TLS/SSL or DTLS enabled
  12. functions
  13. =head1 SYNOPSIS
  14. #include <openssl/ssl.h>
  15. SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
  16. int SSL_CTX_up_ref(SSL_CTX *ctx);
  17. const SSL_METHOD *TLS_method(void);
  18. const SSL_METHOD *TLS_server_method(void);
  19. const SSL_METHOD *TLS_client_method(void);
  20. const SSL_METHOD *SSLv23_method(void);
  21. const SSL_METHOD *SSLv23_server_method(void);
  22. const SSL_METHOD *SSLv23_client_method(void);
  23. #ifndef OPENSSL_NO_SSL3_METHOD
  24. const SSL_METHOD *SSLv3_method(void);
  25. const SSL_METHOD *SSLv3_server_method(void);
  26. const SSL_METHOD *SSLv3_client_method(void);
  27. #endif
  28. #ifndef OPENSSL_NO_TLS1_METHOD
  29. const SSL_METHOD *TLSv1_method(void);
  30. const SSL_METHOD *TLSv1_server_method(void);
  31. const SSL_METHOD *TLSv1_client_method(void);
  32. #endif
  33. #ifndef OPENSSL_NO_TLS1_1_METHOD
  34. const SSL_METHOD *TLSv1_1_method(void);
  35. const SSL_METHOD *TLSv1_1_server_method(void);
  36. const SSL_METHOD *TLSv1_1_client_method(void);
  37. #endif
  38. #ifndef OPENSSL_NO_TLS1_2_METHOD
  39. const SSL_METHOD *TLSv1_2_method(void);
  40. const SSL_METHOD *TLSv1_2_server_method(void);
  41. const SSL_METHOD *TLSv1_2_client_method(void);
  42. #endif
  43. const SSL_METHOD *DTLS_method(void);
  44. const SSL_METHOD *DTLS_server_method(void);
  45. const SSL_METHOD *DTLS_client_method(void);
  46. #ifndef OPENSSL_NO_DTLS1_METHOD
  47. const SSL_METHOD *DTLSv1_method(void);
  48. const SSL_METHOD *DTLSv1_server_method(void);
  49. const SSL_METHOD *DTLSv1_client_method(void);
  50. #endif
  51. #ifndef OPENSSL_NO_DTLS1_2_METHOD
  52. const SSL_METHOD *DTLSv1_2_method(void);
  53. const SSL_METHOD *DTLSv1_2_server_method(void);
  54. const SSL_METHOD *DTLSv1_2_client_method(void);
  55. #endif
  56. =head1 DESCRIPTION
  57. SSL_CTX_new() creates a new B<SSL_CTX> object as framework to
  58. establish TLS/SSL or DTLS enabled connections. An B<SSL_CTX> object is
  59. reference counted. Creating an B<SSL_CTX> object for the first time increments
  60. the reference count. Freeing it (using SSL_CTX_free) decrements it. When the
  61. reference count drops to zero, any memory or resources allocated to the
  62. B<SSL_CTX> object are freed. SSL_CTX_up_ref() increments the reference count for
  63. an existing B<SSL_CTX> structure.
  64. =head1 NOTES
  65. The SSL_CTX object uses B<method> as connection method.
  66. The methods exist in a generic type (for client and server use), a server only
  67. type, and a client only type.
  68. B<method> can be of the following types:
  69. =over 4
  70. =item TLS_method(), TLS_server_method(), TLS_client_method()
  71. These are the general-purpose I<version-flexible> SSL/TLS methods.
  72. The actual protocol version used will be negotiated to the highest version
  73. mutually supported by the client and the server.
  74. The supported protocols are SSLv3, TLSv1, TLSv1.1 and TLSv1.2.
  75. Applications should use these methods, and avoid the version-specific
  76. methods described below.
  77. =item SSLv23_method(), SSLv23_server_method(), SSLv23_client_method()
  78. Use of these functions is deprecated. They have been replaced with the above
  79. TLS_method(), TLS_server_method() and TLS_client_method() respectively. New
  80. code should use those functions instead.
  81. =item TLSv1_2_method(), TLSv1_2_server_method(), TLSv1_2_client_method()
  82. A TLS/SSL connection established with these methods will only understand the
  83. TLSv1.2 protocol.
  84. =item TLSv1_1_method(), TLSv1_1_server_method(), TLSv1_1_client_method()
  85. A TLS/SSL connection established with these methods will only understand the
  86. TLSv1.1 protocol.
  87. =item TLSv1_method(), TLSv1_server_method(), TLSv1_client_method()
  88. A TLS/SSL connection established with these methods will only understand the
  89. TLSv1 protocol.
  90. =item SSLv3_method(), SSLv3_server_method(), SSLv3_client_method()
  91. A TLS/SSL connection established with these methods will only understand the
  92. SSLv3 protocol.
  93. The SSLv3 protocol is deprecated and should not be used.
  94. =item DTLS_method(), DTLS_server_method(), DTLS_client_method()
  95. These are the version-flexible DTLS methods.
  96. Currently supported protocols are DTLS 1.0 and DTLS 1.2.
  97. =item DTLSv1_2_method(), DTLSv1_2_server_method(), DTLSv1_2_client_method()
  98. These are the version-specific methods for DTLSv1.2.
  99. =item DTLSv1_method(), DTLSv1_server_method(), DTLSv1_client_method()
  100. These are the version-specific methods for DTLSv1.
  101. =back
  102. SSL_CTX_new() initializes the list of ciphers, the session cache setting, the
  103. callbacks, the keys and certificates and the options to their default values.
  104. TLS_method(), TLS_server_method(), TLS_client_method(), DTLS_method(),
  105. DTLS_server_method() and DTLS_client_method() are the I<version-flexible>
  106. methods.
  107. All other methods only support one specific protocol version.
  108. Use the I<version-flexible> methods instead of the version specific methods.
  109. If you want to limit the supported protocols for the version flexible
  110. methods you can use L<SSL_CTX_set_min_proto_version(3)>,
  111. L<SSL_set_min_proto_version(3)>, L<SSL_CTX_set_max_proto_version(3)> and
  112. L<SSL_set_max_proto_version(3)> functions.
  113. Using these functions it is possible to choose e.g. TLS_server_method()
  114. and be able to negotiate with all possible clients, but to only
  115. allow newer protocols like TLS 1.0, TLS 1.1 or TLS 1.2.
  116. The list of protocols available can also be limited using the
  117. B<SSL_OP_NO_SSLv3>, B<SSL_OP_NO_TLSv1>, B<SSL_OP_NO_TLSv1_1>,
  118. B<SSL_OP_NO_TLSv1_3> and B<SSL_OP_NO_TLSv1_2> options of the
  119. L<SSL_CTX_set_options(3)> or L<SSL_set_options(3)> functions, but this approach
  120. is not recommended. Clients should avoid creating "holes" in the set of
  121. protocols they support. When disabling a protocol, make sure that you also
  122. disable either all previous or all subsequent protocol versions.
  123. In clients, when a protocol version is disabled without disabling I<all>
  124. previous protocol versions, the effect is to also disable all subsequent
  125. protocol versions.
  126. The SSLv3 protocol is deprecated and should generally not be used.
  127. Applications should typically use L<SSL_CTX_set_min_proto_version(3)> to set
  128. the minimum protocol to at least B<TLS1_VERSION>.
  129. =head1 RETURN VALUES
  130. The following return values can occur:
  131. =over 4
  132. =item NULL
  133. The creation of a new SSL_CTX object failed. Check the error stack to find out
  134. the reason.
  135. =item Pointer to an SSL_CTX object
  136. The return value points to an allocated SSL_CTX object.
  137. SSL_CTX_up_ref() returns 1 for success and 0 for failure.
  138. =back
  139. =head1 HISTORY
  140. Support for SSLv2 and the corresponding SSLv2_method(),
  141. SSLv2_server_method() and SSLv2_client_method() functions where
  142. removed in OpenSSL 1.1.0.
  143. SSLv23_method(), SSLv23_server_method() and SSLv23_client_method()
  144. were deprecated and the preferred TLS_method(), TLS_server_method()
  145. and TLS_client_method() functions were introduced in OpenSSL 1.1.0.
  146. All version-specific methods were deprecated in OpenSSL 1.1.0.
  147. =head1 SEE ALSO
  148. L<SSL_CTX_set_options(3)>, L<SSL_CTX_free(3)>, L<SSL_accept(3)>,
  149. L<SSL_CTX_set_min_proto_version(3)>, L<ssl(7)>, L<SSL_set_connect_state(3)>
  150. =head1 COPYRIGHT
  151. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  152. Licensed under the OpenSSL license (the "License"). You may not use
  153. this file except in compliance with the License. You can obtain a copy
  154. in the file LICENSE in the source distribution or at
  155. L<https://www.openssl.org/source/license.html>.
  156. =cut