Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL: CERTIFICATE_VERIFY_FAILED when upload #740

Closed
DataGeoranger opened this issue Mar 9, 2021 · 3 comments
Closed

SSL: CERTIFICATE_VERIFY_FAILED when upload #740

DataGeoranger opened this issue Mar 9, 2021 · 3 comments
Labels
support Users asking for help using twine

Comments

@DataGeoranger
Copy link

DataGeoranger commented Mar 9, 2021

Your Environment

Thank you for taking the time to report an issue.

To more efficiently resolve this issue, we'd like to know some basic information about your system and setup.

  1. Your operating system: Windows 10

  2. Version of python you are running:

python 3.8.8
  1. How did you install twine? Did you use your operating system's package manager or pip or something else?
    I am using twine to upload package (.tar.gz) to Pypi

  2. Version of twine you have installed (include complete output of):

twine 1.14.0
  1. Which package repository are you targeting?
    Just doing a demo
    A demo

If you're having issues uploading a specific package, you must include a copy of the following:

  • The package's PKG-INFO file
  • A redacted version of your .pypirc file (REMOVE ALL USERNAMES & PASSWORDS BEFORE UPLOADING)

The Issue

I am using this code to upload package. Thank you in advance.

Steps to Reproduce

If the issue is predictable and consistently reproducible, please list the steps here.

twine upload .\dist\geodemopy-0.0.1.tar.gz
Enter your username: I entered my username
Enter your password: I have to copy and paste my password here

Here is the error message:

Enter your username: GeoDataranger
Enter your password: 
Uploading distributions to https://upload.pypi.org/legacy/
Uploading geodemopy-0.0.1.tar.gz
  0%|                                                                                                                                                                             | 0.00/7.24k [00:00<?, ?B/s]
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "c:\programdata\anaconda3\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "c:\programdata\anaconda3\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "c:\programdata\anaconda3\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
    return self.urlopen(
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
    return self.urlopen(
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
    return self.urlopen(
  [Previous line repeated 7 more times]
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "c:\programdata\anaconda3\lib\site-packages\urllib3\util\retry.py", line 573, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='upload.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\programdata\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anacon```da3\Scripts\twine.exe\__main__.py", line 7, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\twine\__main__.py", line 28, in main
    return dispatch(sys.argv[1:])
  File "c:\programdata\anaconda3\lib\site-packages\twine\cli.py", line 77, in dispatch
    return main(args.args)
  File "c:\programdata\anaconda3\lib\site-packages\twine\commands\upload.py", line 137, in main
    return upload(upload_settings, args.dists)
  File "c:\programdata\anaconda3\lib\site-packages\twine\commands\upload.py", line 89, in upload
    resp = repository.upload(package)
  File "c:\programdata\anaconda3\lib\site-packages\twine\repository.py", line 165, in upload
    resp = self._upload(package)
  File "c:\programdata\anaconda3\lib\site-packages\twine\repository.py", line 153, in _upload
    resp = self.session.post(
  File "c:\programdata\anaconda3\lib\site-packages\requests\sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='upload.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))
@sigmavirus24
Copy link
Member

This seems like an issue with your environment. You've also skipped all the questions intended to help us help you in this case. Because this is not a bug in Twine, I'm closing this.

@bhrutledge
Copy link
Contributor

@DataGeoranger It also looks like you're using a very old version of Twine. I think it's unlikely the latest version would resolve your particular issue, but it's worth a shot. There's also a --verbose option that can give you more info.

$ pip install -U twine

$ twine --version
twine version 3.3.0 (pkginfo: 1.7.0, requests: 2.25.1, setuptools: 54.0.0, requests-toolbelt: 0.9.1, tqdm: 4.58.0)

$ twine upload --verbose .\dist\geodemopy-0.0.1.tar.gz

@bhrutledge bhrutledge added the support Users asking for help using twine label Mar 9, 2021
@DataGeoranger
Copy link
Author

DataGeoranger commented Mar 9, 2021

@bhrutledge Thank you very much. I successfully updated twine to 3.3.0 and turn on verbose during uploading. The error message is very similar and please see below. I tried answer questions 1 to 5 and I apologize not answering all the questions, some of them I am not sure where to find when I submitted the bugs. But could you please let me know if any files will be helpful for your to diagnose? I will try my best to provide. Thanks again!

@bhrutledge Hey Brian, also want to provide a link my template package. Thank you and look forward to hearing from you!
github

twine version 3.3.0 (pkginfo: 1.7.0, requests: 2.25.1, setuptools: 52.0.0.post20210125, requests-toolbelt: 0.9.1, tqdm: 4.56.0)
PS C:\Users\Zxwang\geodemopy> twine upload --verbose .\dist\geodemopy-0.0.1.tar.gz
Using configuration from C:\Users\Zxwang/.pypirc
Uploading distributions to https://upload.pypi.org/legacy/
 .\dist\geodemopy-0.0.1.tar.gz (3.0 KB)
Enter your username: GeoDataranger
Enter your password: 
username: GeoDataranger
password: <hidden>
Uploading geodemopy-0.0.1.tar.gz
 0%|                                                                                                                                                                             | 0.00/7.24k [00:01<?, ?B/s]
Traceback (most recent call last):
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
   httplib_response = self._make_request(
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
   self._validate_conn(conn)
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
   conn.connect()
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connection.py", line 411, in connect
   self.sock = ssl_wrap_socket(
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
   ssl_sock = _ssl_wrap_socket_impl(
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
   return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
 File "c:\programdata\anaconda3\lib\ssl.py", line 500, in wrap_socket
   return self.sslsocket_class._create(
 File "c:\programdata\anaconda3\lib\ssl.py", line 1040, in _create
   self.do_handshake()
 File "c:\programdata\anaconda3\lib\ssl.py", line 1309, in do_handshake
   self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "c:\programdata\anaconda3\lib\site-packages\requests\adapters.py", line 439, in send
   resp = conn.urlopen(
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
   return self.urlopen(
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
   return self.urlopen(
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
   return self.urlopen(
 [Previous line repeated 7 more times]
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
   retries = retries.increment(
 File "c:\programdata\anaconda3\lib\site-packages\urllib3\util\retry.py", line 573, in increment
   raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='upload.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "c:\programdata\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
   return _run_code(code, main_globals, None,
 File "c:\programdata\anaconda3\lib\runpy.py", line 87, in _run_code
   exec(code, run_globals)
 File "C:\ProgramData\Anaconda3\Scripts\twine.exe\__main__.py", line 7, in <module>
 File "c:\programdata\anaconda3\lib\site-packages\twine\__main__.py", line 28, in main
   result = cli.dispatch(sys.argv[1:])
 File "c:\programdata\anaconda3\lib\site-packages\twine\cli.py", line 82, in dispatch
   return main(args.args)
 File "c:\programdata\anaconda3\lib\site-packages\twine\commands\upload.py", line 154, in main
   return upload(upload_settings, parsed_args.dists)
 File "c:\programdata\anaconda3\lib\site-packages\twine\commands\upload.py", line 106, in upload
   resp = repository.upload(package)
 File "c:\programdata\anaconda3\lib\site-packages\twine\repository.py", line 195, in upload
   resp = self._upload(package)
 File "c:\programdata\anaconda3\lib\site-packages\twine\repository.py", line 181, in _upload
   resp = self.session.post(
 File "c:\programdata\anaconda3\lib\site-packages\requests\sessions.py", line 590, in post
   return self.request('POST', url, data=data, json=json, **kwargs)
 File "c:\programdata\anaconda3\lib\site-packages\requests\sessions.py", line 542, in request
   resp = self.send(prep, **send_kwargs)
 File "c:\programdata\anaconda3\lib\site-packages\requests\sessions.py", line 655, in send
   r = adapter.send(request, **kwargs)
 File "c:\programdata\anaconda3\lib\site-packages\requests\adapters.py", line 514, in send
   raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='upload.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))

James-E-A added a commit to James-E-A/pypa-twine that referenced this issue Feb 1, 2024
The lack of this has been a *perennial* thorn for people behind
corporate TLS MITM ALG proxies; when it's soluble, it's still
annoying, and sometimes the proxy applications don't use a stable
root bundle, rendering the situation kinda insoluble.

- pypa#328
- pypa#387
- pypa#536
- pypa#740
- pypa#741
- pypa#835
- pypa#915
- pypa#1025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Users asking for help using twine
Projects
None yet
Development

No branches or pull requests

3 participants