Skip to content

Commit 32eba61

Browse files
authored
bpo-43466: Add --with-openssl-rpath configure option (GH-24820)
1 parent ff8c77f commit 32eba61

File tree

9 files changed

+5354
-7444
lines changed

9 files changed

+5354
-7444
lines changed

Doc/using/unix.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,53 @@ some Unices may not have the :program:`env` command, so you may need to hardcode
134134
``/usr/bin/python3`` as the interpreter path.
135135

136136
To use shell commands in your Python scripts, look at the :mod:`subprocess` module.
137+
138+
139+
Custom OpenSSL
140+
==============
141+
142+
1. To use your vendor's OpenSSL configuration and system trust store, locate
143+
the directory with ``openssl.cnf`` file or symlink in ``/etc``. On most
144+
distribution the file is either in ``/etc/ssl`` or ``/etc/pki/tls``. The
145+
directory should also contain a ``cert.pem`` file and/or a ``certs``
146+
directory.
147+
148+
.. code-block:: shell-session
149+
150+
$ find /etc/ -name openssl.cnf -printf "%h\n"
151+
/etc/ssl
152+
153+
2. Download, build, and install OpenSSL. Make sure you use ``install_sw`` and
154+
not ``install``. The ``install_sw`` target does not override
155+
``openssl.cnf``.
156+
157+
.. code-block:: shell-session
158+
159+
$ curl -O https://www.openssl.org/source/openssl-VERSION.tar.gz
160+
$ tar xzf openssl-VERSION
161+
$ pushd openssl-VERSION
162+
$ ./config \
163+
--prefix=/usr/local/custom-openssl \
164+
--openssldir=/etc/ssl
165+
$ make -j1 depend
166+
$ make -j8
167+
$ make install_sw
168+
$ popd
169+
170+
3. Build Python with custom OpenSSL
171+
172+
.. code-block:: shell-session
173+
174+
$ pushd python-3.x.x
175+
$ ./configure -C \
176+
--with-openssl=/usr/local/custom-openssl \
177+
--with-openssl-rpath=auto \
178+
--prefix=/usr/local/python-3.x.x
179+
$ make -j8
180+
$ make altinstall
181+
182+
.. note::
183+
184+
Patch releases of OpenSSL have a backwards compatible ABI. You don't need
185+
to recompile Python to update OpenSSL. It's sufficient to replace the
186+
custom OpenSSL installation with a newer version.

Doc/whatsnew/3.10.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,12 @@ Build Changes
11811181
and ``--with-tcltk-libs`` configuration options.
11821182
(Contributed by Manolis Stamatogiannakis in :issue:`42603`.)
11831183
1184+
* Add ``--with-openssl-rpath`` option to ``configure`` script. The option
1185+
simplifies building Python with a custom OpenSSL installation, e.g.
1186+
``./configure --with-openssl=/path/to/openssl --with-openssl-rpath=auto``.
1187+
(Contributed by Christian Heimes in :issue:`43466`.)
1188+
1189+
11841190
11851191
C API Changes
11861192
=============

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ ENSUREPIP= @ENSUREPIP@
202202
OPENSSL_INCLUDES=@OPENSSL_INCLUDES@
203203
OPENSSL_LIBS=@OPENSSL_LIBS@
204204
OPENSSL_LDFLAGS=@OPENSSL_LDFLAGS@
205+
OPENSSL_RPATH=@OPENSSL_RPATH@
205206

206207
# Default zoneinfo.TZPATH. Added here to expose it in sysconfig.get_config_var
207208
TZPATH=@TZPATH@
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The ``configure`` script now supports ``--with-openssl-rpath`` option.

Tools/ssl/multissltests.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@
4848
]
4949

5050
OPENSSL_RECENT_VERSIONS = [
51-
"1.1.1g",
52-
# "3.0.0-alpha2"
51+
"1.1.1j",
52+
# "3.0.0-alpha12"
5353
]
5454

5555
LIBRESSL_OLD_VERSIONS = [
5656
"2.9.2",
5757
]
5858

5959
LIBRESSL_RECENT_VERSIONS = [
60-
"3.1.0",
60+
"3.2.4",
6161
]
6262

6363
# store files in ../multissl
@@ -169,7 +169,9 @@ class AbstractBuilder(object):
169169
url_templates = None
170170
src_template = None
171171
build_template = None
172+
depend_target = None
172173
install_target = 'install'
174+
jobs = os.cpu_count()
173175

174176
module_files = ("Modules/_ssl.c",
175177
"Modules/_hashopenssl.c")
@@ -321,8 +323,11 @@ def _build_src(self):
321323
if self.system:
322324
env['SYSTEM'] = self.system
323325
self._subprocess_call(cmd, cwd=cwd, env=env)
324-
# Old OpenSSL versions do not support parallel builds.
325-
self._subprocess_call(["make", "-j1"], cwd=cwd, env=env)
326+
if self.depend_target:
327+
self._subprocess_call(
328+
["make", "-j1", self.depend_target], cwd=cwd, env=env
329+
)
330+
self._subprocess_call(["make", f"-j{self.jobs}"], cwd=cwd, env=env)
326331

327332
def _make_install(self):
328333
self._subprocess_call(
@@ -409,6 +414,7 @@ class BuildOpenSSL(AbstractBuilder):
409414
build_template = "openssl-{}"
410415
# only install software, skip docs
411416
install_target = 'install_sw'
417+
depend_target = 'depend'
412418

413419
def _post_install(self):
414420
if self.version.startswith("3.0"):
@@ -434,11 +440,11 @@ def _post_install_300(self):
434440
self.openssl_cli, "fipsinstall",
435441
"-out", fipsinstall_cnf,
436442
"-module", fips_mod,
437-
"-provider_name", "fips",
438-
"-mac_name", "HMAC",
439-
"-macopt", "digest:SHA256",
440-
"-macopt", "hexkey:00",
441-
"-section_name", "fips_sect"
443+
# "-provider_name", "fips",
444+
# "-mac_name", "HMAC",
445+
# "-macopt", "digest:SHA256",
446+
# "-macopt", "hexkey:00",
447+
# "-section_name", "fips_sect"
442448
]
443449
)
444450
with open(openssl_fips_cnf, "w") as f:

aclocal.m4

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ AS_VAR_POPDEF([CACHEVAR])dnl
6767
])dnl AX_CHECK_COMPILE_FLAGS
6868

6969
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
70-
# serial 12 (pkg-config-0.29.2)
70+
# serial 11 (pkg-config-0.29.1)
7171

7272
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
7373
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
@@ -109,7 +109,7 @@ dnl
109109
dnl See the "Since" comment for each macro you use to see what version
110110
dnl of the macros you require.
111111
m4_defun([PKG_PREREQ],
112-
[m4_define([PKG_MACROS_VERSION], [0.29.2])
112+
[m4_define([PKG_MACROS_VERSION], [0.29.1])
113113
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
114114
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
115115
])dnl PKG_PREREQ
@@ -210,7 +210,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
210210
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
211211
212212
pkg_failed=no
213-
AC_MSG_CHECKING([for $2])
213+
AC_MSG_CHECKING([for $1])
214214
215215
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
216216
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -220,11 +220,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
220220
See the pkg-config man page for more details.])
221221
222222
if test $pkg_failed = yes; then
223-
AC_MSG_RESULT([no])
223+
AC_MSG_RESULT([no])
224224
_PKG_SHORT_ERRORS_SUPPORTED
225225
if test $_pkg_short_errors_supported = yes; then
226226
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
227-
else
227+
else
228228
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
229229
fi
230230
# Put the nasty error message in config.log where it belongs
@@ -241,7 +241,7 @@ installed software in a non-standard prefix.
241241
_PKG_TEXT])[]dnl
242242
])
243243
elif test $pkg_failed = untried; then
244-
AC_MSG_RESULT([no])
244+
AC_MSG_RESULT([no])
245245
m4_default([$4], [AC_MSG_FAILURE(
246246
[The pkg-config script could not be found or is too old. Make sure it
247247
is in your PATH or set the PKG_CONFIG environment variable to the full
@@ -342,5 +342,73 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
342342
AS_VAR_IF([$1], [""], [$5], [$4])dnl
343343
])dnl PKG_CHECK_VAR
344344

345+
dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
346+
dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
347+
dnl [DESCRIPTION], [DEFAULT])
348+
dnl ------------------------------------------
349+
dnl
350+
dnl Prepare a "--with-" configure option using the lowercase
351+
dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
352+
dnl PKG_CHECK_MODULES in a single macro.
353+
AC_DEFUN([PKG_WITH_MODULES],
354+
[
355+
m4_pushdef([with_arg], m4_tolower([$1]))
356+
357+
m4_pushdef([description],
358+
[m4_default([$5], [build with ]with_arg[ support])])
359+
360+
m4_pushdef([def_arg], [m4_default([$6], [auto])])
361+
m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
362+
m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
363+
364+
m4_case(def_arg,
365+
[yes],[m4_pushdef([with_without], [--without-]with_arg)],
366+
[m4_pushdef([with_without],[--with-]with_arg)])
367+
368+
AC_ARG_WITH(with_arg,
369+
AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
370+
[AS_TR_SH([with_]with_arg)=def_arg])
371+
372+
AS_CASE([$AS_TR_SH([with_]with_arg)],
373+
[yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
374+
[auto],[PKG_CHECK_MODULES([$1],[$2],
375+
[m4_n([def_action_if_found]) $3],
376+
[m4_n([def_action_if_not_found]) $4])])
377+
378+
m4_popdef([with_arg])
379+
m4_popdef([description])
380+
m4_popdef([def_arg])
381+
382+
])dnl PKG_WITH_MODULES
383+
384+
dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
385+
dnl [DESCRIPTION], [DEFAULT])
386+
dnl -----------------------------------------------
387+
dnl
388+
dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
389+
dnl check._[VARIABLE-PREFIX] is exported as make variable.
390+
AC_DEFUN([PKG_HAVE_WITH_MODULES],
391+
[
392+
PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
393+
394+
AM_CONDITIONAL([HAVE_][$1],
395+
[test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
396+
])dnl PKG_HAVE_WITH_MODULES
397+
398+
dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
399+
dnl [DESCRIPTION], [DEFAULT])
400+
dnl ------------------------------------------------------
401+
dnl
402+
dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
403+
dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
404+
dnl and preprocessor variable.
405+
AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
406+
[
407+
PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
408+
409+
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
410+
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
411+
])dnl PKG_HAVE_DEFINE_WITH_MODULES
412+
345413
m4_include([m4/ax_c_float_words_bigendian.m4])
346414
m4_include([m4/ax_check_openssl.m4])

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy