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

SOLVED - SSLError(SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),),) #4930

Closed
akuardit opened this Issue Mar 24, 2017 · 10 comments

Comments

Projects
None yet
10 participants
@akuardit

akuardit commented Mar 24, 2017

cannot install anything, create environment, or conda update conda

conda update conda -v
Fetching package metadata ...An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues

overtaking stderr and stdout

stderr and stdout yielding back

Current conda install:

           platform : win-64
      conda version : 4.3.14
   conda is private : False
  conda-env version : 4.3.14
conda-build version : not installed
     python version : 3.6.0.final.0
   requests version : 2.12.4
   root environment : D:\dev\Anaconda3  (writable)
default environment : D:\dev\Anaconda3
   envs directories : D:\dev\Anaconda3\envs
                      C:\Users\user\AppData\Local\conda\conda\envs
                      C:\Users\user\DOCUME~1\MOBAXT~1\home\.conda\envs
      package cache : D:\dev\Anaconda3\pkgs
                      C:\Users\user\AppData\Local\conda\conda\pkgs
       channel URLs : https://conda.anaconda.org/conda-forge/win-64
                      https://conda.anaconda.org/conda-forge/noarch
                      https://conda.anaconda.org/conda-canary/win-64
                      https://conda.anaconda.org/conda-canary/noarch
        config file : C:\Users\user\DOCUME~1\MOBAXT~1\home\.condarc
       offline mode : False
         user-agent : conda/4.3.14 requests/2.12.4 CPython/3.6.0 Windows/10 Windows/10.0.14393

$ D:\dev\Anaconda3\Scripts\conda-script.py update conda -v

Traceback (most recent call last):
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 417, in wrap_socket
    cnx.do_handshake()
  File "D:\dev\Anaconda3\lib\site-packages\OpenSSL\SSL.py", line 1426, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "D:\dev\Anaconda3\lib\site-packages\OpenSSL\SSL.py", line 1174, in _raise_ssl_error
    _raise_current_error()
  File "D:\dev\Anaconda3\lib\site-packages\OpenSSL\_util.py", line 48, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 350, in _make_request
    self._validate_conn(conn)
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 835, in _validate_conn
    conn.connect()
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 323, in connect
    ssl_context=context)
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 324, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 424, in wrap_socket
    raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\dev\Anaconda3\lib\site-packages\requests\adapters.py", line 423, in send
    timeout=timeout
  File "D:\dev\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 624, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\repodata.py", line 138, in fetch_repodata_remote_request
    timeout=timeout)
  File "D:\dev\Anaconda3\lib\site-packages\requests\sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "D:\dev\Anaconda3\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\dev\Anaconda3\lib\site-packages\requests\sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "D:\dev\Anaconda3\lib\site-packages\requests\adapters.py", line 497, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\dev\Anaconda3\lib\site-packages\conda\exceptions.py", line 573, in conda_exception_handler
    return_value = func(*args, **kwargs)
  File "D:\dev\Anaconda3\lib\site-packages\conda\cli\main.py", line 134, in _main
    exit_code = args.func(args, p)
  File "D:\dev\Anaconda3\lib\site-packages\conda\cli\main_update.py", line 65, in execute
    install(args, parser, 'update')
  File "D:\dev\Anaconda3\lib\site-packages\conda\cli\install.py", line 222, in install
    unknown=index_args['unknown'], prefix=prefix)
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\index.py", line 92, in get_index
    index = fetch_index(channel_priority_map, use_cache=use_cache)
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\index.py", line 111, in fetch_index
    repodatas = collect_all_repodata(use_cache, tasks)
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\repodata.py", line 74, in collect_all_repodata
    repodatas = _collect_repodatas_serial(use_cache, tasks)
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\repodata.py", line 463, in _collect_repodatas_serial
    for url, schan, pri in tasks]
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\repodata.py", line 463, in <listcomp>
    for url, schan, pri in tasks]
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\repodata.py", line 109, in func
    res = f(*args, **kwargs)
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\repodata.py", line 442, in fetch_repodata
    mod_etag_headers.get('_mod'))
  File "D:\dev\Anaconda3\lib\site-packages\conda\core\repodata.py", line 305, in fetch_repodata_remote_request
    e.response)
conda.exceptions.CondaHTTPError: HTTP None None for url <https://conda.anaconda.org/conda-forge/win-64/repodata.json>
Elapsed: None

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),),)
@kilojoules

This comment has been minimized.

Show comment
Hide comment
@kilojoules

kilojoules Mar 30, 2017

Solved this with conda config --set ssl_verify False

kilojoules commented Mar 30, 2017

Solved this with conda config --set ssl_verify False

@akuardit

This comment has been minimized.

Show comment
Hide comment
@akuardit

akuardit Apr 13, 2017

@kilojoules, doesn't work on my laptop.

SOLVED...
Iam using windows 10 pro, never work with Mobaxterm 9/10, so move to Cmder.

  • download cacert.pem from https://curl.haxx.se/ca/cacert.pem, save to c:\Cmder\cacert.pem
  • open, c:\Cmder\config\user-profile.sh
    add this line, ... export REQUESTS_CA_BUNDLE=/c/Cmder/cacert.pem ...
  • run, Cmder ->new console -> {bash::bash as Admin}

now can do anything with conda

akuardit commented Apr 13, 2017

@kilojoules, doesn't work on my laptop.

SOLVED...
Iam using windows 10 pro, never work with Mobaxterm 9/10, so move to Cmder.

  • download cacert.pem from https://curl.haxx.se/ca/cacert.pem, save to c:\Cmder\cacert.pem
  • open, c:\Cmder\config\user-profile.sh
    add this line, ... export REQUESTS_CA_BUNDLE=/c/Cmder/cacert.pem ...
  • run, Cmder ->new console -> {bash::bash as Admin}

now can do anything with conda

@akuardit akuardit changed the title from SSLError(SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),),) to SOLVED - SSLError(SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),),) Apr 13, 2017

@kalefranz kalefranz closed this May 1, 2017

@schattenjagerPL

This comment has been minimized.

Show comment
Hide comment
@schattenjagerPL

schattenjagerPL Sep 6, 2017

Hi just one hint for people struggling with this problem

Solved this with conda config --set ssl_verify False

This did not resolve problem for me. But i just noticed that when you enter this operation then anaconda creates user config file (.condarc) in his home directory (.e.g c:\Users\username\ ) and inside a file ssl_verify was set to True. Change it manually, save file and try again. I`m just downloading packages so it had to work.

Update:
It is probably related to user rights. I don`t have local admin on my account so running conda config from command line did not work

schattenjagerPL commented Sep 6, 2017

Hi just one hint for people struggling with this problem

Solved this with conda config --set ssl_verify False

This did not resolve problem for me. But i just noticed that when you enter this operation then anaconda creates user config file (.condarc) in his home directory (.e.g c:\Users\username\ ) and inside a file ssl_verify was set to True. Change it manually, save file and try again. I`m just downloading packages so it had to work.

Update:
It is probably related to user rights. I don`t have local admin on my account so running conda config from command line did not work

@Pijju789

This comment has been minimized.

Show comment
Hide comment
@Pijju789

Pijju789 Jan 30, 2018

"conda config --set ssl_verify False" working fine for "conda update conda" command. but throwing me error for "pip install eli5"

Pijju789 commented Jan 30, 2018

"conda config --set ssl_verify False" working fine for "conda update conda" command. but throwing me error for "pip install eli5"

@WolfDSCoder

This comment has been minimized.

Show comment
Hide comment
@WolfDSCoder

WolfDSCoder Apr 24, 2018

I am trying to fix the SSL bad handshake error and have tried many different methods. Nothing seems to solve the problem. I'm using Windows 10.

My attempts included:

Same error occurs. No change. I can't use Conda or Anaconda for installing packages or creating environments so this is a very frustrating error.

At the Anaconda prompt, I try: conda update conda, and get the following error:

Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.continuum.io/pkgs/free/win-64/repodata.json.bz2
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(MaxRetryError('HTTPSConnectionPool(host='repo.continuum.io', port=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.json.bz2 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))',),)

Here is my environment:
conda version : 4.4.10
conda-build version : 3.4.1
python version : 3.6.4.final.0

Thank you for any assistance.

WolfDSCoder commented Apr 24, 2018

I am trying to fix the SSL bad handshake error and have tried many different methods. Nothing seems to solve the problem. I'm using Windows 10.

My attempts included:

Same error occurs. No change. I can't use Conda or Anaconda for installing packages or creating environments so this is a very frustrating error.

At the Anaconda prompt, I try: conda update conda, and get the following error:

Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.continuum.io/pkgs/free/win-64/repodata.json.bz2
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(MaxRetryError('HTTPSConnectionPool(host='repo.continuum.io', port=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.json.bz2 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))',),)

Here is my environment:
conda version : 4.4.10
conda-build version : 3.4.1
python version : 3.6.4.final.0

Thank you for any assistance.

@Code4SAFrankie

This comment has been minimized.

Show comment
Hide comment
@Code4SAFrankie

Code4SAFrankie May 15, 2018

conda config --set ssl_verify False solves the Anaconda issue, but it does not solve the pip issue

Code4SAFrankie commented May 15, 2018

conda config --set ssl_verify False solves the Anaconda issue, but it does not solve the pip issue

@bmond

This comment has been minimized.

Show comment
Hide comment
@bmond

bmond May 16, 2018

Any resolution found for this?

bmond commented May 16, 2018

Any resolution found for this?

@WolfDSCoder

This comment has been minimized.

Show comment
Hide comment
@WolfDSCoder

WolfDSCoder May 16, 2018

SOLVED.

The problem was that the environment variable REQUESTS_CA_BUNDLE was not set in the Anaconda Prompt shell profile, or any other command shell profile such as Git or Cmdr. Below are the steps I used to correct this in the various shells. You only have to set this variable in the shell you are using.

You can verify REQUESTS_CA_BUNDLE is set in the shell by typing 'conda info -s' then look at the REQUESTS_CA_BUNDLE entry in the list, which in my case was not set.

For Anaconda Prompt -- You need to enter the 'set' command each time since it is not saved. Copy and paste the following at the prompt, but change the {username} to your own computer.
set REQUESTS_CA_BUNDLE=C:\users\{username}\anaconda3\Lib\site-packages\certifi\cacert.pem

For CMDR -- (Cmder is a console emulator downloaded from cmder.net)
Open the following profile file in a text editor: C:\cmder\config\user-profile.sh
Then insert the following line:
export REQUESTS_CA_BUNDLE='C:\users\{username}\anaconda3\Lib\site-packages\certifi\cacert.pem'
Then run Cmdr and open a new console -> {bash::bash as Admin}
You can now use the Cmdr shell to run conda.

For Git Bash shell
Open the following profile file in a text editor: C:\users{username}.bashrc
Then insert the following line:
export REQUESTS_CA_BUNDLE='C:\users\{username}\anaconda3\Lib\site-packages\certifi\cacert.pem'
You can now use the Git Bash shell to run conda.

Notes:
If you don't have the cacert.pem file in the certifi folder mentioned above, you can download it from

If anyone knows how to set the environment variable REQUESTS_CA_BUNDLE to be permanent in the Anaconda Prompt, please let me know. In the meantime, I created a batch.bat file to set it each time and run the Anaconda Prompt from there.

Now conda works. Hurray!

WolfDSCoder commented May 16, 2018

SOLVED.

The problem was that the environment variable REQUESTS_CA_BUNDLE was not set in the Anaconda Prompt shell profile, or any other command shell profile such as Git or Cmdr. Below are the steps I used to correct this in the various shells. You only have to set this variable in the shell you are using.

You can verify REQUESTS_CA_BUNDLE is set in the shell by typing 'conda info -s' then look at the REQUESTS_CA_BUNDLE entry in the list, which in my case was not set.

For Anaconda Prompt -- You need to enter the 'set' command each time since it is not saved. Copy and paste the following at the prompt, but change the {username} to your own computer.
set REQUESTS_CA_BUNDLE=C:\users\{username}\anaconda3\Lib\site-packages\certifi\cacert.pem

For CMDR -- (Cmder is a console emulator downloaded from cmder.net)
Open the following profile file in a text editor: C:\cmder\config\user-profile.sh
Then insert the following line:
export REQUESTS_CA_BUNDLE='C:\users\{username}\anaconda3\Lib\site-packages\certifi\cacert.pem'
Then run Cmdr and open a new console -> {bash::bash as Admin}
You can now use the Cmdr shell to run conda.

For Git Bash shell
Open the following profile file in a text editor: C:\users{username}.bashrc
Then insert the following line:
export REQUESTS_CA_BUNDLE='C:\users\{username}\anaconda3\Lib\site-packages\certifi\cacert.pem'
You can now use the Git Bash shell to run conda.

Notes:
If you don't have the cacert.pem file in the certifi folder mentioned above, you can download it from

If anyone knows how to set the environment variable REQUESTS_CA_BUNDLE to be permanent in the Anaconda Prompt, please let me know. In the meantime, I created a batch.bat file to set it each time and run the Anaconda Prompt from there.

Now conda works. Hurray!

@SpaceDustPi

This comment has been minimized.

Show comment
Hide comment
@SpaceDustPi

SpaceDustPi Aug 2, 2018

The Anaconda Prompt option did not work for me, but I can clearly see the "set REQUESTS..." command worked after typing the "conda info -s" command. "Do you have to do this as an administrator?

SpaceDustPi commented Aug 2, 2018

The Anaconda Prompt option did not work for me, but I can clearly see the "set REQUESTS..." command worked after typing the "conda info -s" command. "Do you have to do this as an administrator?

@WolfDSCoder

This comment has been minimized.

Show comment
Hide comment
@WolfDSCoder

WolfDSCoder Aug 2, 2018

You might try it as an Administrator and see if that works.

When you say the Anaconda Prompt option did not work for you, but you can see the command worked, is your system working? Does REQUESTS_CA_BUNDLE have the correct path displayed?

WolfDSCoder commented Aug 2, 2018

You might try it as an Administrator and see if that works.

When you say the Anaconda Prompt option did not work for you, but you can see the command worked, is your system working? Does REQUESTS_CA_BUNDLE have the correct path displayed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment