Alpine 3.3, Python 2.7.11, urllib2 causing SSL: CERTIFICATE_VERIFY_FAILED

前端 未结 2 1675
感动是毒
感动是毒 2021-01-17 14:10

I have this small Dockerfile

FROM alpine:3.3
RUN apk --update add python
CMD [\"python\", \"-c\", \"import urllib2; response = urllib2.urlopen(\'https://www.         


        
相关标签:
2条回答
  • 2021-01-17 14:14

    You need to install ca-certificates to be able to validate signed certs by public CAs:

    FROM alpine:3.3
    RUN apk --no-cache add python ca-certificates
    CMD ["python", "-c", "import urllib2; response = urllib2.urlopen('https://www.python.org')"]
    
    0 讨论(0)
  • 2021-01-17 14:26

    You will need to upgrade Alpine as libssl needs to be upgraded with a patch

    FROM alpine:3.3
    RUN apk -U upgrade && \
        apk -U add python ca-certificates && \
        update-ca-certificates
    CMD ["python", "-c", "import urllib2; response = urllib2.urlopen('https://www.python.org')"]
    

    apk -U upgrade will upgrade these:

    • libcrypto1.0 (1.0.2e-r0 -> 1.0.2g-r0)
    • libssl1.0 (1.0.2e-r0 -> 1.0.2g-r0)
    0 讨论(0)
提交回复
热议问题