不能;pip安装加密技术“;在Docker Alpine Linux 3.3中,使用OpenSSL 1.0.2g和Python 2.7

不能;pip安装加密技术“;在Docker Alpine Linux 3.3中,使用OpenSSL 1.0.2g和Python 2.7,python,linux,openssl,dockerfile,alpine,Python,Linux,Openssl,Dockerfile,Alpine,解决了哇,这些家伙真快。。。基本上就是这样,结果是openssl的一个安全更新被发布(溺水攻击),并且该更新包含一个意外的函数签名更改,这导致了不兼容,所以这对我来说是个坏运气 我需要在运行Alpine Linux的Docker容器中使用pip安装加密技术。实际上,它是另一个模块,service\u identity,但问题在于加密模块,它是一个依赖项 我有下面的Dockerfile FROM alpine:3.3 RUN apk --update add build-base libffi

解决了哇,这些家伙真快。。。基本上就是这样,结果是openssl的一个安全更新被发布(溺水攻击),并且该更新包含一个意外的函数签名更改,这导致了不兼容,所以这对我来说是个坏运气


我需要在运行Alpine Linux的Docker容器中使用
pip安装加密技术。实际上,它是另一个模块,
service\u identity
,但问题在于
加密
模块,它是一个依赖项

我有下面的Dockerfile

FROM alpine:3.3

RUN apk --update add build-base libffi-dev openssl-dev python-dev py-pip
RUN pip install cryptography
它将失败,并出现以下错误

generating cffi module 'build/temp.linux-x86_64-2.7/_openssl.c'
building '_openssl' extension
creating build/temp.linux-x86_64-2.7/build
creating build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7
gcc -fno-strict-aliasing -Os -fomit-frame-pointer -DNDEBUG -Os -fomit-frame-pointer -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o
build/temp.linux-x86_64-2.7/_openssl.c:726:6: error: conflicting types for 'BIO_new_mem_buf'
 BIO *BIO_new_mem_buf(void *, int);
      ^
In file included from /usr/include/openssl/asn1.h:65:0,
                 from build/temp.linux-x86_64-2.7/_openssl.c:434:
/usr/include/openssl/bio.h:692:6: note: previous declaration of 'BIO_new_mem_buf' was here
 BIO *BIO_new_mem_buf(const void *buf, int len);
      ^
error: command 'gcc' failed with exit status 1
openssl 1.0.2g于2016-03-01(昨天)发布,alpine软件包已更新至该版本。是否与此有关

我如何解决这个问题?也许我可以设置一些环境变量

更新我一直在检查GitHub的openssl回购协议,事实上,
BIO*BIO\u new\u mem\u buf(void*buf,int len)
openssl/BIO.h
BIO*BIO\u new\u mem\u buf(const void*buf,int len)
在1.0.2f到1.0.2g的过渡期间(在中搜索“BIO\u new\u mem\u buf”)。我不知道这个
openssl/asn1.h
是从哪里来的,它导入了一个过时版本的
openssl/bio.h
,因为它看起来不像openssl repo中的版本。有什么想法吗

好的,我看到一些人已经在做这个了:
对于那些在Alpine 3.7中安装
加密==2.1.4
时仍遇到问题的用户,如下所示:

writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
running build_ext
generating cffi module 'build/temp.linux-x86_64-2.7/_padding.c'
creating build/temp.linux-x86_64-2.7
generating cffi module 'build/temp.linux-x86_64-2.7/_constant_time.c'
generating cffi module 'build/temp.linux-x86_64-2.7/_openssl.c'
building '_openssl' extension
creating build/temp.linux-x86_64-2.7/build
creating build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7
gcc -fno-strict-aliasing -Os -fomit-frame-pointer -g -DNDEBUG -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o -Wconversion -Wno-error=sign-conversion
build/temp.linux-x86_64-2.7/_openssl.c:493:30: fatal error: openssl/opensslv.h: No such file or directory
 #include <openssl/opensslv.h>
                              ^
compilation terminated.
error: command 'gcc' failed with exit status 1
要使用Dockerfile安装这些依赖项,请执行以下操作:

参考文献 Alpine上的
加密
安装说明可在以下位置找到:

  • 从写作时起的版本
以下是相关部分:

在Linux上构建加密 [跳过非Alpine Linux的部分]

$pip安装加密
如果你在阿尔卑斯山上,或者只是想自己编译它
cryptography
需要一个编译器,用于Python的头文件(如果您不是 使用
pypy
),以及OpenSSL和
libffi
库的头文件 在您的系统上可用

阿尔卑斯山 如果您使用的是python 2,请将
python3-dev
替换为
python-dev

$sudo apk add gcc musl dev python3 dev libffi dev openssl dev
如果您在
openssl-dev
中遇到错误,您可能必须使用
libressl-dev


在安装之前添加以下内容:

运行apk-U升级


运行apk add--no cache libffi dev openssl dev

如果由于生锈版本而失败,则建议在密码学文档中使用以下内容:

The Rust available by default in Alpine < 3.12 is older than the 
minimum supported version. See the Rust installation instructions
 for information about installing a newer Rust.

在我的例子中,python3.8-alpine添加了
cargo
解决了问题。

我今天安装了加密1.2.2,升级到1.2.3解决了同样的问题。谢谢你的回答。如果链接失效,请详细说明答案中的代码。请重新编辑您的答案
加密
模块的开发人员当时解决了这个问题,该模块与
OpenSSL
库不同步。您在这里提到的方法将
OpenSSL
替换为
LibreSSL
。它提供了一种变通方法,而不是解决方案。像
tini
这样的库真的需要吗?感谢您提供了另一种方法(我假设它有效,但不会尝试)。在重新排列代码以获得正确的格式时,我注意到您实际上没有安装模块
cryptography
@DanielF Btw,我在示例中包括了tini和其他库,而不是实际的解决方案。如果它太偏离了,我会删除它……这应该是公认的答案
The Rust available by default in Alpine < 3.12 is older than the 
minimum supported version. See the Rust installation instructions
 for information about installing a newer Rust.