Skip to content

Mysteriously inconsistent SSL Cert behavior with different nixpkgs versions / apps for a particular site #8867

Closed

Description

@obadz
$ nix-shell --pure -p python34 -p python34Packages.dbus 
[nix-shell:~]$ python3
Python 3.4.3 (default, Jan 01 1970, 00:00:01) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>> urllib.request.urlopen("https://news.google.com");
Traceback (most recent call last):
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/urllib/request.py", line 1182, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/http/client.py", line 1088, in request
    self._send_request(method, url, body, headers)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/http/client.py", line 1126, in _send_request
    self.endheaders(body)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/http/client.py", line 1084, in endheaders
    self._send_output(message_body)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/http/client.py", line 922, in _send_output
    self.send(msg)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/http/client.py", line 857, in send
    self.connect()
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/http/client.py", line 1231, in connect
    server_hostname=server_hostname)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/ssl.py", line 365, in wrap_socket
    _context=self)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/ssl.py", line 583, in __init__
    self.do_handshake()
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/ssl.py", line 810, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/urllib/request.py", line 161, in urlopen
    return opener.open(url, data, timeout)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/urllib/request.py", line 463, in open
    response = self._open(req, data)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/urllib/request.py", line 481, in _open
    '_open', req)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/urllib/request.py", line 441, in _call_chain
    result = func(*args)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/urllib/request.py", line 1225, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/nix/store/1kfab8hs8d94f9n0xcscn6pzyqkwc9g1-python3-3.4.3/lib/python3.4/urllib/request.py", line 1184, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)>

Cc @domenkozar

Activity

  1. obadz commented on Jul 17, 2015

    @obadz
    ContributorAuthor

    Nevermind setting SSL_CERT_FILE fixes it.

  2. reopened this on Jul 17, 2015
  3. obadz commented on Jul 17, 2015

    @obadz
    ContributorAuthor

    Reopening: this fails for

    >> urllib.request.urlopen("https://internal-tuner.pandora.com/");
    

    whereas the cert looks fine when opening in Chromium.

  4. obadz commented on Jul 17, 2015

    @obadz
    ContributorAuthor

    image

  5. copumpkin commented on Jul 17, 2015

    @copumpkin
    Member

    @obadz would probably help if you included the type of failure. Does it just not know the root? Consider the certificate malformed? Some other violation?

  6. obadz commented on Jul 17, 2015

    @obadz
    ContributorAuthor

    exception is visibly identical to the one I pasted above:

    urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)>
    

    Not sure how I can get more details.

    Looks like this error isn't specific to Python: curl also complains about the cert:

    $ curl https://internal-tuner.pandora.com/                             
    curl: (60) SSL certificate problem: unable to get local issuer certificate
    More details here: http://curl.haxx.se/docs/sslcerts.html
    

    Maybe an issue with cacert? Does chromium not use cacert (I don't see a reference to it in the Chromium nix file)?

  7. vcunat commented on Jul 18, 2015

    @vcunat
    Member

    Are you sure that your curl can see that SSL_CERT_FILE variable? Beware of nix-shell --pure for this! EDIT: my curl https://internal-tuner.pandora.com/ works fine.

  8. reopened this on Jul 18, 2015
  9. obadz commented on Jul 18, 2015

    @obadz
    ContributorAuthor

    Further details on trying to access https://internal-tuner.pandora.com/:

    @vcunat on staging:
    Could access with: curl, firefox
    Got cert error with: python

    @kmicu on "master~40ish"
    Could access with: nothing
    Got cert error with: curl, python, conkeror (firefox), chromium (every app)

    @obadz on nixos-unstable (6ad8fab):
    Could access with: firefox, chromium
    Got cert error with: curl, python

    @lethalman on older unstable:
    Could access with: chromium

    Everyone could access https://news.google.com/ from all apps.

    @vcunat, @kmicu & myself have matching md5sum $SSL_CERT_FILE

    [EDITED to fix @vcunat 's observations and clarify]

  10. changed the title [-]Python 3.4: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)[/-] [+]Mysteriously inconsistent SSL Cert behavior with different nixpkgs versions / apps for a particular site[/+] on Jul 18, 2015
  11. obadz commented on Jul 18, 2015

    @obadz
    ContributorAuthor

    Should clarify: "able to access" = "no cert validation error"

  12. vcunat commented on Jul 18, 2015

    @vcunat
    Member

    No, I'm the other way. Curl and FF get no cert error and python3 does.

  13. obadz commented on Jul 18, 2015

    @obadz
    ContributorAuthor

    Edited comment to reflect that.

  14. obadz commented on Jul 18, 2015

    @obadz
    ContributorAuthor

    Ok ignore previous comment, fixing observations and summarizing gives us this:

    For https://internal-tuner.pandora.com/:

    Browsers (Chromium, Firefox) think certs are fine.
    Python thinks certs are invalid.
    Curl thinks certs are invalid on nixos-unstable/master but Ok on staging.

    https://news.google.com/ works for all apps.

    md5sum $SSL_CERT_FILE remains constant throughout

  15. globin commented on Jul 18, 2015

    @globin
    Member

    Nixos-built cargo (not binary snapshot) has similar problems #8872

  16. FRidh commented on Jul 1, 2016

    @FRidh
    Member

    Is this the same as #15571? If not, please reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions