【发布时间】:2020-03-05 00:09:40
【问题描述】:
我正在尝试从容器中的源代码构建 Python 和 OpenSSL。两者似乎都正确构建,但 Python 没有成功创建 _ssl 模块。
我在网上找到了一个 few guides 表示取消注释和来自 Python-3.X.X/Modules/Setup 的行,并将 --openssldir=/usr/local/ssl 标志添加到 OpenSSL 的 ./configure 步骤。我在我的 dockerfile 中执行这些操作。这导致在 Python 的 ./configure 输出期间,我看到以下行。
checking for X509_VERIFY_PARAM_set1_host in libssl... yes
但我收到以下错误:
[91m*** WARNING: renaming "_ssl" since importing it failed: /usr/lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by build/lib.linux-x86_64-3.8/_ssl.cpython-38-x86_64-linux-gnu.so)
[0m[91m*** WARNING: renaming "_hashlib" since importing it failed: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_1' not found (required by build/lib.linux-x86_64-3.8/_hashlib.cpython-38-x86_64-linux-gnu.so)
[0m
Python build finished successfully!
...
Following modules built successfully but were removed because they could not be imported:
_hashlib _ssl
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
如果 ./configure 找到 X509...,为什么我仍然收到 hashlib 和 ssl 错误?
完整的 Dockerfile,FWIW:
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && apt-get install -y apt-utils gcc make zlib1g-dev \
build-essential libffi-dev checkinstall libsqlite3-dev
RUN wget https://www.openssl.org/source/openssl-1.1.1d.tar.gz && \
tar xzf openssl-1.1.1d.tar.gz && \
cd openssl-1.1.1d && \
./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' --prefix=/usr/local/ssl --openssldir=/usr/local/ssl && \
make && \
make test && \
make install
RUN wget -q https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz && \
tar -xzf Python-3.8.2.tgz && \
cd Python-3.8.2 && \
./configure && \
make && \
make install
USER jenkins
【问题讨论】:
-
嗨,Jake,你为什么不能在
Python/Modules/Setup中添加那行?你可以做一个sed对文件进行适当的更改。 -
正在尝试...
sed -i 's|# -DUSE_SSL| -DUSE_SSL| w /dev/stdout' Python-3.8.2/Modules/Setup。在我的机器上它可以工作,在 dockerfile 上它没有。 -
甚至让它在 Dockerfile 上运行也会给出:
[91m./python: /usr/lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by ./python) [0mgenerate-posix-vars failed Makefile:592: recipe for target 'pybuilddir.txt' failed [91mmake: *** [pybuilddir.txt] Error 1 [0m
标签: python linux docker ssl openssl