I have created a fresh Docker image:
FROM ubuntu:18.04
# Install dependencies
RUN apt-get update
RUN apt-get install -y build-essential g++ curl openssl libssl-dev apache2-utils git libxml2-dev sshfs libbz2-dev libsqlite3-dev tk-dev libffi-dev libreadline-dev libfreetype6-dev libpng-dev
# Install Python
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile && \
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile && \
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile && \
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
RUN source ~/.bash_profile && \
pyenv install 3.7-dev && \
pyenv virtualenv 3.7-dev venv && \
pyenv global venv && \
pip install -U pip
However, after running this in a container, I am unable to access any websites due to a certificate issue. This is happening both in Python (3.6 & 3.7) and openssl:
openssl s_client -connect discordapp.com:443
openssl s_client -connect python.org:443
openssl s_client -connect google.com:443
All return the same error: Verify return code: 20 (unable to get local issuer certificate)
In Python, it gives me (when discord.py
tries to connect to discordapp.com
:
SSL handshake failed on verifying the certificate
protocol: <asyncio.sslproto.SSLProtocol object at 0x7fd78479c6d8>
transport: <_SelectorSocketTransport fd=6 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
File "/root/.pyenv/versions/3.7-dev/lib/python3.7/asyncio/sslproto.py", line 625, in _on_handshake_complete
raise handshake_exc
File "/root/.pyenv/versions/3.7-dev/lib/python3.7/asyncio/sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "/root/.pyenv/versions/3.7-dev/lib/python3.7/ssl.py", line 763, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1048)
SSL error in data received
I attempted to update my certificates with apt-get install ca-certificates
, but the command states that this package is already up to date.
How can I fix this?