8000 [3.8] bpo-43799: OpenSSL 3.0.0: declare OPENSSL_API_COMPAT 1.1.1 (GH-… · python/cpython@b71aaa0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b71aaa0

Browse files
authored
[3.8] bpo-43799: OpenSSL 3.0.0: declare OPENSSL_API_COMPAT 1.1.1 (GH-25329) (GH-25383)
Signed-off-by: Christian Heimes <christian@python.org>. (cherry picked from commit a483388)
1 parent f396a1a commit b71aaa0

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OpenSSL 3.0.0: define ``OPENSSL_API_COMPAT`` 1.1.1 to suppress deprecation
2+
warnings. Python requires OpenSSL 1.1.1 APIs.

Modules/_hashopenssl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
*
1212
*/
1313

14+
/* Don't warn about deprecated functions, */
15+
#ifndef OPENSSL_API_COMPAT
16+
// 0x10101000L == 1.1.1, 30000 == 3.0.0
17+
#define OPENSSL_API_COMPAT 0x10101000L
18+
#endif
19+
#define OPENSSL_NO_DEPRECATED 1
20+
1421
#define PY_SSIZE_T_CLEAN
1522

1623
#include "Python.h"
@@ -24,7 +31,7 @@
2431
#include <openssl/hmac.h>
2532
/* We use the object interface to discover what hashes OpenSSL supports. */
2633
#include <openssl/objects.h>
27-
#include "openssl/err.h"
34+
#include <openssl/err.h>
2835

2936
#ifndef OPENSSL_THREADS
3037
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"

Modules/_ssl.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
http://bugs.python.org/issue8108#msg102867 ?
1515
*/
1616

17+
/* Don't warn about deprecated functions, */
18+
#ifndef OPENSSL_API_COMPAT
19+
// 0x10101000L == 1.1.1, 30000 == 3.0.0
20+
#define OPENSSL_API_COMPAT 0x10101000L
21+
#endif
22+
#define OPENSSL_NO_DEPRECATED 1
23+
1724
#define PY_SSIZE_T_CLEAN
1825

1926
#include "Python.h"
@@ -45,14 +52,6 @@ static PySocketModule_APIObject PySocketModule;
4552
#include <sys/poll.h>
4653
#endif
4754

48-
/* Don't warn about deprecated functions */
49-
#ifdef __GNUC__
50-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
51-
#endif
52-
#ifdef __clang__
53-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
54-
#endif
55-
5655
/* Include OpenSSL header files */
5756
#include "openssl/rsa.h"
5857
#include "openssl/crypto.h"
@@ -150,24 +149,20 @@ static void _PySSLFixErrno(void) {
150149
# define PY_OPENSSL_1_1_API 1
151150
#endif
152151

153-
/* OpenSSL API compat */
154-
#ifdef OPENSSL_API_COMPAT
155-
#if OPENSSL_API_COMPAT >= 0x10100000L
156-
157-
/* OpenSSL API 1.1.0+ does not include version methods */
152+
/* OpenSSL API 1.1.0+ does not include version methods. Define the methods
153+
* unless OpenSSL is compiled without the methods. It's the easiest way to
154+
* make 1.0.2, 1.1.0, 1.1.1, and 3.0.0 happy without deprecation warnings.
155+
*/
158156
#ifndef OPENSSL_NO_TLS1_METHOD
159-
#define OPENSSL_NO_TLS1_METHOD 1
157+
extern const SSL_METHOD *TLSv1_method(void);
160158
#endif
161159
#ifndef OPENSSL_NO_TLS1_1_METHOD
162-
#define OPENSSL_NO_TLS1_1_METHOD 1
160+
extern const SSL_METHOD *TLSv1_1_method(void);
163161
#endif
164162
#ifndef OPENSSL_NO_TLS1_2_METHOD
165-
#define OPENSSL_NO_TLS1_2_METHOD 1
163+
extern const SSL_METHOD *TLSv1_2_method(void);
166164
#endif
167165

168-
#endif /* >= 1.1.0 compcat */
169-
#endif /* OPENSSL_API_COMPAT */
170-
171166
/* LibreSSL 2.7.0 provides necessary OpenSSL 1.1.0 APIs */
172167
#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070000fL
173168
# define PY_OPENSSL_1_1_API 1

0 commit comments

Comments
 (0)
0