{"action":"created","issue":{"url":"https://api.github.com/repos/requests/requests/issues/4382","repository_url":"https://api.github.com/repos/requests/requests","labels_url":"https://api.github.com/repos/requests/requests/issues/4382/labels{/name}","comments_url":"https://api.github.com/repos/requests/requests/issues/4382/comments","events_url":"https://api.github.com/repos/requests/requests/issues/4382/events","html_url":"https://github.com/requests/requests/issues/4382","id":273081514,"number":4382,"title":"request fails with bad handshake error","user":{"login":"uttampawar","id":8977402,"avatar_url":"https://avatars3.githubusercontent.com/u/8977402?v=4","gravatar_id":"","url":"https://api.github.com/users/uttampawar","html_url":"https://github.com/uttampawar","followers_url":"https://api.github.com/users/uttampawar/followers","following_url":"https://api.github.com/users/uttampawar/following{/other_user}","gists_url":"https://api.github.com/users/uttampawar/gists{/gist_id}","starred_url":"https://api.github.com/users/uttampawar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uttampawar/subscriptions","organizations_url":"https://api.github.com/users/uttampawar/orgs","repos_url":"https://api.github.com/users/uttampawar/repos","events_url":"https://api.github.com/users/uttampawar/events{/privacy}","received_events_url":"https://api.github.com/users/uttampawar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-10T22:42:54Z","updated_at":"2017-11-14T18:57:48Z","closed_at":"2017-11-14T18:57:48Z","author_association":"NONE","body":"Summary.\r\nI've a node.js server running with local certificate for SSL connection created using openssl command as,\r\n```\r\n$ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost'   -keyout localhost-privkey.pem -out localhost-cert.pem\r\n```\r\n\r\nTrying to use requests module to initiate communication with this node.js server which fails with various errors.\r\n## Reproduction Steps\r\n```python\r\n>>> import requests\r\n>>> requests.get(\"https://localhost:9000/getcpuinfo\")\r\n...\r\nrequests.exceptions.SSLError: (\"bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)\",)\r\n```\r\n\r\nSo I tried to pass verify=False option as,\r\n```\r\n>>>  requests.get(\"https://localhost:9000/getcpuinfo\", verify=False)\r\nequests.exceptions.SSLError: (\"bad handshake: SysCallError(-1, 'Unexpected EOF')\",)\r\n```\r\n\r\nI tested the server with \"curl\" utility as shown below,\r\n```\r\n$ curl  https://localhost:9000/loaddb\r\ncurl: (60) SSL certificate problem: self signed certificate <--- fails \r\n```\r\n\r\nBut it works with \"-k\" to ignore certificate verification step,\r\n```\r\n$ curl -k  https://localhost:9000/getcpuinfo\r\n{\"hw\":{\"architecture\":\"x64\",\"model\":\"Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz\",\"speed\":899,\"sys\":3600700,\"irq\":0,\"idle\":2617236700,\"user\":17612800,\"nice\":39400,\"endianness\":\"LE\",\"totalmem\":33605652480,\"freemem\":27233288192},\"sw\":{\"platform\":\"linux\",\"release\":\"4.9.0-3-amd64\",\"type\":\"Linux\",\"uptime\":265048},\"appName\":\"Cluster\",\"version\":{\"http_parser\":\"2.7.0\",\"node\":\"9.0.0-pre\",\"v8\":\"6.1.534.42\",\"uv\":\"1.14.1\",\"zlib\":\"1.2.11\",\"ares\":\"1.13.0\",\"modules\":\"58\",\"nghttp2\":\"1.25.0\",\"openssl\":\"1.0.2l\",\"icu\":\"59.1\",\"unicode\":\"9.0\",\"cldr\":\"31.0.1\",\"tz\":\"2017b\"},\"cpuCount\":0}\r\n```\r\n\r\nSo why doesn't requests module ignores certificate validation when \"verify=False\"?\r\n\r\nEnvironment details:\r\nOS: \r\n  Linux nodejs-work 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux\r\nPython:\r\n  Python 2.7.13 (default, Jan 19 2017, 14:48:08) \r\n  [GCC 6.3.0 20170118] on linux2\r\n\r\nClient/Public certificate (localhost-cert.pem),\r\n```\r\n----BEGIN CERTIFICATE-----\r\nMIIC/jCCAeagAwIBAgIJAKATu2AY/QT4MA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNV\r\nBAMMCWxvY2FsaG9zdDAeFw0xNzExMDkyMTQ1NTBaFw0xNzEyMDkyMTQ1NTBaMBQx\r\nEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\r\nggEBAJTPk5nao0wG/EDFGnq7BvXMkEZ5oUVq7PAUxWi+E/byJk924l7Z5kACgWBa\r\nzQL0lLXLpdMk97EFGWMblz5Ehtqh7U8HaE9OZ6x/pesDTka+REnpXecklRrdZHX7\r\nlfFnNIU58grPpB2GyUXrRdOtcPlaKXUo+VTd7PgwMtYVtt8pyTWxSB2MMYrqJGT8\r\n78KX6trRzQLm7tas3U0jD59+R8j7gxU6FyFaNJBrkJ5T9kHGKOsAzSqZdCgRBjl5\r\ni7xcXJfOAAnZ3jhGlY5DQht+HZDHhjkLG9kcZZhFDYteFk8drzbd3lBw96nLq+8A\r\nSy92FtQL4GiYSwZ0WVAmwmTCGjUCAwEAAaNTMFEwHQYDVR0OBBYEFLYjwGKbcV9h\r\nsYHxe8l9UvXVivByMB8GA1UdIwQYMBaAFLYjwGKbcV9hsYHxe8l9UvXVivByMA8G\r\nA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHl7okBCJlms+cwfzLhs\r\nsbyyuX2wgngxyvjy497zBmeh1TiueGPhOx9u/sfJSZmoUaeRd/zPGkp2DcPQ+Lo2\r\nEHYrXMPE1Ecgpu/15JZ8jNuE+FwZb9lllULLwzq8pDkdbdsSRltdV/rFlZ2YkscB\r\nc+xvVaCltw5KpKnY6AWHoqwoDcd8TZKzyKXLSuluKbHNC1lvg8cMzs6hFA9P92Ae\r\n9P08AKLAIOGJ7QzRrXQIsAO4p9rHheeZeYQZyNiRrXPQUoWos4+OjynaNs+FabhN\r\nXBtSl/GGPRRRfU/D9v4iKfQx15CEvs1AKn1Z6mIPF05pSqbgIoz2mJBV6UM7e+hz\r\nTRs=\r\n-----END CERTIFICATE-----\r\n```"},"comment":{"url":"https://api.github.com/repos/requests/requests/issues/comments/344361090","html_url":"https://github.com/requests/requests/issues/4382#issuecomment-344361090","issue_url":"https://api.github.com/repos/requests/requests/issues/4382","id":344361090,"user":{"login":"Lukasa","id":1382556,"avatar_url":"https://avatars1.githubusercontent.com/u/1382556?v=4","gravatar_id":"","url":"https://api.github.com/users/Lukasa","html_url":"https://github.com/Lukasa","followers_url":"https://api.github.com/users/Lukasa/followers","following_url":"https://api.github.com/users/Lukasa/following{/other_user}","gists_url":"https://api.github.com/users/Lukasa/gists{/gist_id}","starred_url":"https://api.github.com/users/Lukasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lukasa/subscriptions","organizations_url":"https://api.github.com/users/Lukasa/orgs","repos_url":"https://api.github.com/users/Lukasa/repos","events_url":"https://api.github.com/users/Lukasa/events{/privacy}","received_events_url":"https://api.github.com/users/Lukasa/received_events","type":"User","site_admin":false},"created_at":"2017-11-14T18:57:48Z","updated_at":"2017-11-14T18:57:48Z","author_association":"OWNER","body":"Requests *is* ignoring the certificate validation: the server you're using is closing the connection in our face after it sends the certificate to us. That is an issue with your server."}}
{"actor":{"display_login":"Lukasa"}}