python package does not depend on ca-certificates
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python3-defaults (Debian) |
Fix Released
|
Unknown
|
|||
python3.6 (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
Bionic |
New
|
Undecided
|
Unassigned | ||
Focal |
New
|
Undecided
|
Unassigned | ||
python3.8 (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
Bionic |
New
|
Undecided
|
Unassigned | ||
Focal |
New
|
Undecided
|
Unassigned | ||
python3.9 (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
Bionic |
New
|
Undecided
|
Unassigned | ||
Focal |
New
|
Undecided
|
Unassigned |
Bug Description
(Affects all Python versions)
Python has no dependency on ca-certificates. Installing Python on a minimal Debian or Ubuntu container image does not pull in ca-certificates. This results in certificate validation issues as no trust anchors are available. Python's ssl module and ssl.create_
Since Python 2.7.9 and 3.4.0 the ssl module encourages developers to use ssl.create_
Reproducer:
# docker run -ti ubuntu:bionic /bin/bash
# apt-get update
# apt-get install -y python3
# ls -la /etc/ssl/
ls: cannot access '/etc/ssl/
# dpkg -l ca-certificates
Desired=
| Status=
|/ Err?=(none)
||/ Name Version Architecture Description
+++-===
un ca-certificates <none> <none> (no description available)
# python3 -c 'from urllib.request import urlopen; urlopen("https:/
Traceback (most recent call last):
...
urllib.
# echo $?
1
# apt-get install -y ca-certificates
# python3 -c 'from urllib.request import urlopen; urlopen("https:/
root@seneca:/# echo $?
0
Proposed solution:
Either all Python interpreter packages or libssl should pull in ca-certificates.
I have reported the bug on Debian's bug tracker as well, https:/
Changed in python3-defaults (Debian): | |
status: | Unknown → New |
Changed in python3-defaults (Debian): | |
status: | New → Fix Released |
Latest Ubuntu release is still broken:
$ cat Dockerfile. ubuntu- groovy
FROM ubuntu:groovy
RUN apt update && \
apt upgrade -y && \
apt install -y python3 && \
apt clean
RUN python3 -c 'from urllib.request import urlopen; urlopen("https:/ /www.pypi. org")'
$ podman build -f Dockerfile. ubuntu- groovy bf9ffe7b308da61 d7d0262c741d624 ebfacea6b277cef 2fbd /www.pypi. org")' python3. 8/urllib/ request. py", line 1350, in do_open req.get_ method( ), req.selector, req.data, headers, python3. 8/http/ client. py", line 1255, in request _send_request( method, url, body, headers, encode_chunked) python3. 8/http/ client. py", line 1301, in _send_request endheaders( body, encode_ chunked= encode_ chunked) python3. 8/http/ client. py", line 1250, in endheaders _send_output( message_ body, encode_ chunked= encode_ chunked) python3. 8/http/ client. py", line 1010, in _send_output python3. 8/http/ client. py", line 950, in send python3. 8/http/ client. py", line 1424, in connect wrap_socket( self.sock, python3. 8/ssl.py" , line 500, in wrap_socket class._ create( python3. 8/ssl.py" , line 1040, in _create do_handshake( ) python3. 8/ssl.py" , line 1309, in do_handshake _sslobj. do_handshake( ) ficationError: [SSL: CERTIFICATE_ VERIFY_ FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)
STEP 1: FROM ubuntu:groovy
STEP 2: RUN apt update && apt upgrade -y && apt install -y python3 && apt clean
--> Using cache 199e6b47bba512f
--> 199e6b47bba
STEP 3: RUN python3 -c 'from urllib.request import urlopen; urlopen("https:/
Traceback (most recent call last):
File "/usr/lib/
h.request(
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
self.send(msg)
File "/usr/lib/
self.connect()
File "/usr/lib/
self.sock = self._context.
File "/usr/lib/
return self.sslsocket_
File "/usr/lib/
self.
File "/usr/lib/
self.
ssl.SSLCertVeri
The issue can be fixed with a simple one-line change to debian/control to install ca-certificates by default. curl has the same recommends stanza.
Package: python3.8
...
Recommends: ca-certificates