Dan*_*l F 11 python linux openssl dockerfile alpine-linux
解决了哇,这些家伙很快......基本上就是这个https://github.com/pyca/cryptography/issues/2750事实证明,openssl的安全更新已经发布(DROWN Attack),并且该更新包含了一个意想不到的功能签名更改导致不兼容,所以这对我来说只是运气不好.
我需要pip install cryptography在运行Alpine Linux的Docker容器中使用.实际上,它是另一个模块,service_identity但问题在于cryptography模块,它是一个依赖项.
我有以下Dockerfile
FROM alpine:3.3
RUN apk --update add build-base libffi-dev openssl-dev python-dev py-pip
RUN pip install cryptography
Run Code Online (Sandbox Code Playgroud)
失败,出现以下错误
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
Run Code Online (Sandbox Code Playgroud)
openssl 1.0.2g于2016-03-01(昨天)发布,alpine软件包已经更新到该版本.它可以与此相关吗?
我该如何解决这个问题?也许我可以设置一些环境变量?
更新我已经检查GitHub库OpenSSL的,而事实上BIO *BIO_new_mem_buf(void *buf, int len)的openssl/bio.h得到了改变,以BIO *BIO_new_mem_buf(const void *buf, int len)在1.0.2f期间1.0.2g转变(在搜索"BIO_new_mem_buf" https://github.com/openssl/openssl/compare/ OpenSSL_1_0_2f ... OpenSSL_1_0_2g).我不知道这openssl/asn1.h是从哪里来的,这是导入过时的版本openssl/bio.h,因为它看起来不像openssl repo中的那个.有任何想法吗?
好的,我看到一些人已经在努力了:https: //github.com/pyca/cryptography/issues/2750
小智 11
仍然在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
Run Code Online (Sandbox Code Playgroud)
解决方案:
apk add --no-cache libressl-dev musl-dev libffi-dev
范例:
RUN apk add --no-cache \
libressl-dev \
musl-dev \
libffi-dev && \
pip install --no-cache-dir cryptography==2.1.4 && \
apk del libressl-dev \
musl-dev \
libffi-dev
Run Code Online (Sandbox Code Playgroud)
应该解决。
参考:
https://github.com/pyca/cryptography/blob/master/docs/installation.rst
如果链接过期:
$ pip install cryptography
如果您使用的是Alpine或只是想自己编译,则加密需要编译器,Python的标头(如果您未使用pypy)以及系统上可用的OpenSSL和libffi库的标头。
高山的
如果您使用的是Python 2,请用python-dev替换python3-dev。
$ sudo apk add gcc musl-dev python3-dev libffi-dev openssl-dev
如果您遇到错误,则openssl-dev可能必须使用libressl-dev。
muo*_*uon 10
如果由于 Rust 版本而失败,则建议在密码学的文档中执行以下操作:
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.
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
就我而言,python3.8-alpine,添加已cargo解决。