6

When I tried to push a new package to my company's artifactory :

python -m twine upload --repository-url https:///artifactory/api/pypi/gdp_pypi dist/*

I got an error on SSL. ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)

Any way to disable the SSL verification?

3

3 Answers 3

2

I just tried the solution by another post: Disable Python requests SSL validation for an imported module

Simply setting environment variable CURL_CA_BUNDLE to an empty string did the job!

$ export CURL_CA_BUNDLE=""

1
1

Setting an empty string as suggested above doesn't seem to work anymore:

$ export CURL_CA_BUNDLE=""

BUT, when I navigated to my organization's Github in the browser (where the cert was installed and working) and downloaded the .crt for the first cert in the chain, then it DID work when setting the variable to that .crt file.

$ export CURL_CA_BUNDLE="/path/to/cert.crt"
0

The workaround using CURL_CA_BUNDLE described in "Disable Python requests SSL validation for an imported module" doesn't work anymore.

Possible solution is to use separate script which could be named twine-trusted containing the following code:

import twine.__main__
import twine.repository

def disable_server_certificate_validation():
    "Allow twine to just trust the hosts"
    twine.repository.Repository.set_certificate_authority = lambda *args, **kwargs: None


def main():
    disable_server_certificate_validation()
    twine.__main__.main()

__name__ == '__main__' and main()

Source: https://github.com/pypa/twine/pull/463#issuecomment-556892003

Not the answer you're looking for? Browse other questions tagged or ask your own question.