You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
5.3 KiB

  1. From 3f3b85a59d3c2cb021174ad92ad3a43d9eb73e62 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Fri, 7 Jun 2019 21:00:46 -0700
  4. Subject: [PATCH] Add compatibility for deprecated TLS methods
  5. ---
  6. src/_cffi_src/openssl/ssl.py | 45 +++++++++++++++++--
  7. .../hazmat/bindings/openssl/_conditional.py | 36 +++++++++++++++
  8. 2 files changed, 77 insertions(+), 4 deletions(-)
  9. diff --git a/src/_cffi_src/openssl/ssl.py b/src/_cffi_src/openssl/ssl.py
  10. index c38e309a..e726417d 100644
  11. --- a/src/_cffi_src/openssl/ssl.py
  12. +++ b/src/_cffi_src/openssl/ssl.py
  13. @@ -15,8 +15,9 @@ static const long Cryptography_HAS_SSL_ST;
  14. static const long Cryptography_HAS_TLS_ST;
  15. static const long Cryptography_HAS_SSL2;
  16. static const long Cryptography_HAS_SSL3_METHOD;
  17. -static const long Cryptography_HAS_TLSv1_1;
  18. -static const long Cryptography_HAS_TLSv1_2;
  19. +static const long Cryptography_HAS_TLS1_METHOD;
  20. +static const long Cryptography_HAS_TLS1_1_METHOD;
  21. +static const long Cryptography_HAS_TLS1_2_METHOD;
  22. static const long Cryptography_HAS_TLSv1_3;
  23. static const long Cryptography_HAS_SECURE_RENEGOTIATION;
  24. static const long Cryptography_HAS_TLSEXT_STATUS_REQ_CB;
  25. @@ -24,6 +25,7 @@ static const long Cryptography_HAS_STATUS_REQ_OCSP_RESP;
  26. static const long Cryptography_HAS_TLSEXT_STATUS_REQ_TYPE;
  27. static const long Cryptography_HAS_SSL_CTX_CLEAR_OPTIONS;
  28. static const long Cryptography_HAS_DTLS;
  29. +static const long Cryptography_HAS_DTLS1_METHOD;
  30. static const long Cryptography_HAS_SIGALGS;
  31. static const long Cryptography_HAS_PSK;
  32. static const long Cryptography_HAS_CIPHER_DETAILS;
  33. @@ -596,8 +598,43 @@ static const long Cryptography_HAS_STATUS_REQ_OCSP_RESP = 1;
  34. static const long Cryptography_HAS_TLSEXT_STATUS_REQ_TYPE = 1;
  35. static const long Cryptography_HAS_RELEASE_BUFFERS = 1;
  36. static const long Cryptography_HAS_OP_NO_COMPRESSION = 1;
  37. -static const long Cryptography_HAS_TLSv1_1 = 1;
  38. -static const long Cryptography_HAS_TLSv1_2 = 1;
  39. +
  40. +#if (OPENSSL_API_COMPAT >= 0x10100000L) && !CRYPTOGRAPHY_IS_LIBRESSL
  41. +static const long Cryptography_HAS_TLS1_METHOD = 0;
  42. +const SSL_METHOD* (*TLSv1_method)(void) = NULL;
  43. +const SSL_METHOD* (*TLSv1_server_method)(void) = NULL;
  44. +const SSL_METHOD* (*TLSv1_client_method)(void) = NULL;
  45. +#else
  46. +static const long Cryptography_HAS_TLS1_METHOD = 1;
  47. +#endif
  48. +
  49. +#if (OPENSSL_API_COMPAT >= 0x10100000L) && !CRYPTOGRAPHY_IS_LIBRESSL
  50. +static const long Cryptography_HAS_TLS1_1_METHOD = 0;
  51. +const SSL_METHOD* (*TLSv1_1_method)(void) = NULL;
  52. +const SSL_METHOD* (*TLSv1_1_server_method)(void) = NULL;
  53. +const SSL_METHOD* (*TLSv1_1_client_method)(void) = NULL;
  54. +#else
  55. +static const long Cryptography_HAS_TLS1_1_METHOD = 1;
  56. +#endif
  57. +
  58. +#if (OPENSSL_API_COMPAT >= 0x10100000L) && !CRYPTOGRAPHY_IS_LIBRESSL
  59. +static const long Cryptography_HAS_TLS1_2_METHOD = 0;
  60. +const SSL_METHOD* (*TLSv1_2_method)(void) = NULL;
  61. +const SSL_METHOD* (*TLSv1_2_server_method)(void) = NULL;
  62. +const SSL_METHOD* (*TLSv1_2_client_method)(void) = NULL;
  63. +#else
  64. +static const long Cryptography_HAS_TLS1_2_METHOD = 1;
  65. +#endif
  66. +
  67. +#if (OPENSSL_API_COMPAT >= 0x10100000L) && !CRYPTOGRAPHY_IS_LIBRESSL
  68. +static const long Cryptography_HAS_DTLS1_METHOD = 0;
  69. +const SSL_METHOD* (*DTLSv1_method)(void) = NULL;
  70. +const SSL_METHOD* (*DTLSv1_server_method)(void) = NULL;
  71. +const SSL_METHOD* (*DTLSv1_client_method)(void) = NULL;
  72. +#else
  73. +static const long Cryptography_HAS_DTLS1_METHOD = 1;
  74. +#endif
  75. +
  76. static const long Cryptography_HAS_SSL_OP_MSIE_SSLV2_RSA_PADDING = 1;
  77. static const long Cryptography_HAS_SSL_OP_NO_TICKET = 1;
  78. static const long Cryptography_HAS_SSL_SET_SSL_CTX = 1;
  79. diff --git a/src/cryptography/hazmat/bindings/openssl/_conditional.py b/src/cryptography/hazmat/bindings/openssl/_conditional.py
  80. index 23dc38a4..c0dca00a 100644
  81. --- a/src/cryptography/hazmat/bindings/openssl/_conditional.py
  82. +++ b/src/cryptography/hazmat/bindings/openssl/_conditional.py
  83. @@ -33,6 +33,38 @@ def cryptography_has_ssl3_method():
  84. ]
  85. +def cryptography_has_tls1_method():
  86. + return [
  87. + "TLSv1_method",
  88. + "TLSv1_client_method",
  89. + "TLSv1_server_method",
  90. + ]
  91. +
  92. +
  93. +def cryptography_has_tls1_1_method():
  94. + return [
  95. + "TLSv1_1_method",
  96. + "TLSv1_1_client_method",
  97. + "TLSv1_1_server_method",
  98. + ]
  99. +
  100. +
  101. +def cryptography_has_tls1_2_method():
  102. + return [
  103. + "TLSv1_2_method",
  104. + "TLSv1_2_client_method",
  105. + "TLSv1_2_server_method",
  106. + ]
  107. +
  108. +
  109. +def cryptography_has_dtls1_method():
  110. + return [
  111. + "DTLSv1_method",
  112. + "DTLSv1_client_method",
  113. + "DTLSv1_server_method",
  114. + ]
  115. +
  116. +
  117. def cryptography_has_102_verification():
  118. return [
  119. "X509_V_ERR_SUITE_B_INVALID_VERSION",
  120. @@ -303,6 +335,10 @@ CONDITIONAL_NAMES = {
  121. "Cryptography_HAS_RSA_OAEP_MD": cryptography_has_rsa_oaep_md,
  122. "Cryptography_HAS_RSA_OAEP_LABEL": cryptography_has_rsa_oaep_label,
  123. "Cryptography_HAS_SSL3_METHOD": cryptography_has_ssl3_method,
  124. + "Cryptography_HAS_TLS1_METHOD": cryptography_has_tls1_method,
  125. + "Cryptography_HAS_TLS1_1_METHOD": cryptography_has_tls1_1_method,
  126. + "Cryptography_HAS_TLS1_2_METHOD": cryptography_has_tls1_2_method,
  127. + "Cryptography_HAS_DTLS1_METHOD": cryptography_has_dtls1_method,
  128. "Cryptography_HAS_102_VERIFICATION": cryptography_has_102_verification,
  129. "Cryptography_HAS_110_VERIFICATION_PARAMS": (
  130. cryptography_has_110_verification_params
  131. --
  132. 2.26.2