bpo-32598: Use autoconf to detect usable OpenSSL (#5242) · pythoncapi/cpython@ff5be6e · GitHub
Skip to content

Commit ff5be6e

Browse files
authored
bpo-32598: Use autoconf to detect usable OpenSSL (python#5242)
Add https://www.gnu.org/software/autoconf-archive/ax_check_openssl.html to auto-detect compiler flags, linker flags and libraries to compile OpenSSL extensions. The M4 macro uses pkg-config and falls back to manual detection. Add autoconf magic to detect usable X509_VERIFY_PARAM_set1_host() and related functions. Refactor setup.py to use new config vars to compile _ssl and _hashlib modules. Signed-off-by: Christian Heimes <christian@python.org>
1 parent d911e40 commit ff5be6e

9 files changed

Lines changed: 585 additions & 83 deletions

File tree

Makefile.pre.in

Lines changed: 5 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Use autoconf to detect OpenSSL libs, headers and supported features. The
2+
ax_check_openssl M4 macro uses pkg-config to locate OpenSSL and falls back
3+
to manual search.

Modules/_ssl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ static PySocketModule_APIObject PySocketModule;
6464
#include "openssl/rand.h"
6565
#include "openssl/bio.h"
6666

67+
/* Set HAVE_X509_VERIFY_PARAM_SET1_HOST for non-autoconf builds */
68+
#ifndef HAVE_X509_VERIFY_PARAM_SET1_HOST
69+
# if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER > 0x1000200fL
70+
# define HAVE_X509_VERIFY_PARAM_SET1_HOST
71+
# endif
72+
#endif
73+
6774
/* SSL error object */
6875
static PyObject *PySSLErrorObject;
6976
static PyObject *PySSLCertVerificationErrorObject;

aclocal.m4

Lines changed: 73 additions & 4 deletions

0 commit comments

Comments
 (0)