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

Skip to content

Commit a483388

Browse files
authored
bpo-43799: OpenSSL 3.0.0: declare OPENSSL_API_COMPAT 1.1.1 (GH-25329)
Signed-off-by: Christian Heimes <christian@python.org>
1 parent d2a8e69 commit a483388

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@
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"
1724
#include "hashlib.h"
1825
#include "pystrhex.h"
1926

20-
2127
/* EVP is the preferred interface to hashing in OpenSSL */
2228
#include <openssl/evp.h>
2329
#include <openssl/hmac.h>
2430
#include <openssl/crypto.h>
2531
/* We use the object interface to discover what hashes OpenSSL supports. */
2632
#include <openssl/objects.h>
27-
#include "openssl/err.h"
33+
#include <openssl/err.h>
2834

2935
#include <openssl/crypto.h> // FIPS_mode()
3036

@@ -1862,12 +1868,11 @@ _hashlib_get_fips_mode_impl(PyObject *module)
18621868
/*[clinic end generated code: output=87eece1bab4d3fa9 input=2db61538c41c6fef]*/
18631869

18641870
{
1865-
int result;
18661871
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
1867-
result = EVP_default_properties_is_fips_enabled(NULL);
1872+
return EVP_default_properties_is_fips_enabled(NULL);
18681873
#else
18691874
ERR_clear_error();
1870-
result = FIPS_mode();
1875+
int result = FIPS_mode();
18711876
if (result == 0) {
18721877
// "If the library was built without support of the FIPS Object Module,
18731878
// then the function will return 0 with an error code of

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"
@@ -43,14 +50,6 @@ static PySocketModule_APIObject PySocketModule;
4350
#include <sys/poll.h>
4451
#endif
4552

46-
/* Don't warn about deprecated functions */
47-
#ifdef __GNUC__
48-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
49-
#endif
50-
#ifdef __clang__
51-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
52-
#endif
53-
5453
/* Include OpenSSL header files */
5554
#include "openssl/rsa.h"
5655
#include "openssl/crypto.h"
@@ -148,24 +147,20 @@ static void _PySSLFixErrno(void) {
148147
# define PY_OPENSSL_1_1_API 1
149148
#endif
150149

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

166-
#endif /* >= 1.1.0 compcat */
167-
#endif /* OPENSSL_API_COMPAT */
168-
169164
/* LibreSSL 2.7.0 provides necessary OpenSSL 1.1.0 APIs */
170165
#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070000fL
171166
# define PY_OPENSSL_1_1_API 1

0 commit comments

Comments
 (0)
0