Skip to content

Commit

Permalink
Add ssl context when downloading classifiers
Browse files Browse the repository at this point in the history
Closes #57.
  • Loading branch information
abravalheri committed Sep 1, 2022
1 parent ff15772 commit 1e3d75c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/validate_pyproject/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ def pep517_backend_reference(value: str) -> bool:

def _download_classifiers() -> str:
import cgi
import ssl
from urllib.request import urlopen

url = "https://pypi.org/pypi?:action=list_classifiers"
with urlopen(url) as response:
context = ssl.create_default_context()
with urlopen(url, context=context) as response:
content_type = response.getheader("content-type", "text/plain")
encoding = cgi.parse_header(content_type)[1].get("charset", "utf-8")
return response.read().decode(encoding)
Expand Down

0 comments on commit 1e3d75c

Please sign in to comment.