I use python version 2.7.6 and need to make a request using TLSv1.2. I tried something like this to specify the version of tls:
class SslAdapter[]:
def init_poolmanager[self, connections, maxsize, block=False]:
self.poolmanager = PoolManager[num_pools=connections,
maxsize=maxsize,
block=block,
ssl_version=ssl.PROTOCOL_TLSv1_2]
s=requests.Session[]
s.mount['//', SslAdapter[]]
s.get['//google.com',verify=False]
But in debugger i see that version of TLS in request is TLSv1.0. Can you suggest how to properly specify TLS version? Thanks.
Cố gắng thực hiện một yêu cầu nhận đơn giản bằng cách sử dụng phiên yêu cầu nhưng tôi tiếp tục nhận được SSLError cho một trang web cụ thể. Tôi nghĩ rằng có lẽ vấn đề là với trang web [tôi đã quét bằng cách sử dụng //www.ssllabs.com, kết quả đã xuống dưới đây], nhưng tôi không thể chắc chắn vì tôi không có kiến thức trong lĩnh vực này :] Tôi chắc chắn muốn để hiểu những gì đang xảy ra.
Nội dung chính ShowShow
- Kết quả dự kiến
- Kết quả thực tế
- Các bước tái tạo
- Thông tin hệ thống
- Lỗi bắt tay xấu là gì?
- Điều gì gây ra lỗi chứng chỉ SSL Python?
- Giấy chứng nhận xác minh có nghĩa là gì?
- Yêu cầu Python có sử dụng HTTPS không?
Yêu cầu xác minh chứng chỉ SSL cho các yêu cầu HTTPS, giống như trình duyệt web., just like a web browser.
Cố gắng thực hiện một yêu cầu nhận đơn giản bằng cách sử dụng phiên yêu cầu nhưng tôi tiếp tục nhận được SSLError cho một trang web cụ thể. Tôi nghĩ rằng có lẽ vấn đề là với trang web [tôi đã quét bằng cách sử dụng //www.ssllabs.com, kết quả đã xuống dưới đây], nhưng tôi không thể chắc chắn vì tôi không có kiến thức trong lĩnh vực này :] Tôi chắc chắn muốn để hiểu những gì đang xảy ra.
import requests
requests.get['//www.reporo.com/']
Nội dung chính Show
SSLError: [Errno bad handshake] [['SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed']]
---------------------------------------------------------------------------
SSLError Traceback [most recent call last]
in []
----> 1 requests.get['//www.reporo.com/']
/usr/local/lib/python2.7/dist-packages/requests/api.pyc in get[url, **kwargs]
63
64 kwargs.setdefault['allow_redirects', True]
---> 65 return request['get', url, **kwargs]
66
67
/usr/local/lib/python2.7/dist-packages/requests/api.pyc in request[method, url, **kwargs]
47
48 session = sessions.Session[]
---> 49 response = session.request[method=method, url=url, **kwargs]
50 # By explicitly closing the session, we avoid leaving sockets open which
51 # can trigger a ResourceWarning in some cases, and look like a memory leak
/usr/local/lib/python2.7/dist-packages/requests/sessions.pyc in request[self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json]
459 }
460 send_kwargs.update[settings]
--> 461 resp = self.send[prep, **send_kwargs]
462
463 return resp
/usr/local/lib/python2.7/dist-packages/requests/sessions.pyc in send[self, request, **kwargs]
571
572 # Send the request
--> 573 r = adapter.send[request, **kwargs]
574
575 # Total elapsed time of the request [approximately]
/usr/local/lib/python2.7/dist-packages/requests/adapters.pyc in send[self, request, stream, timeout, verify, cert, proxies]
429 except [_SSLError, _HTTPError] as e:
430 if isinstance[e, _SSLError]:
--> 431 raise SSLError[e, request=request]
432 elif isinstance[e, ReadTimeoutError]:
433 raise ReadTimeout[e, request=request]
SSLError: [Errno bad handshake] [['SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed']]
Kết quả dự kiến
SSL Report: reporo.com
Assessed on: Sun Feb 22 21:42:57 PST 2015 | Clear cache Scan Another >>
Server Domain[s] Test time Grade
1 154.51.128.13
Certificate not valid for domain name
reporo.com
Sun Feb 22 21:40:53 PST 2015
Duration: 9.167 sec -
2 198.12.15.168
protected.ddosdefend.com
Ready
www.reporo.com
Sun Feb 22 21:41:02 PST 2015
Duration: 115.189 sec
F
Kết quả thực tế
Thanks in advance!
Các bước tái tạo
openssl s_client -showcerts -connect server:44300
CONNECTED[00000003]
depth=0 CN = server
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 CN = server
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/CN=server
i:/CN=server
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=server
issuer=/CN=server
---
No client certificate CA names sent
Peer signing digest: SHA1
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 1477 bytes and written 431 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES256-GCM-SHA384
Session-ID: CC4A000083B1E03B446416C9C0B16CBEAB79949E3CF5C936A309A6F92FA01364
Session-ID-ctx:
Master-Key: 798A570B0EC2A0CBB7C4C4DE6167E7579A92239942D869CD794B8BEBEA6EB5E492394634AD32665A8BB829DE1F3858D2
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1510329948
Timeout : 300 [sec]
Verify return code: 21 [unable to verify the first certificate]
---
Kết quả dự kiến
Kết quả thực tế
curl //server:44300 --cacert /usr/share/ca-certificates/server.crt
HTTP/1.1 403 Forbidden
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Length: 1158
Content-Type: text/html
Server: Microsoft-IIS/10.0
X-Frame-Options: SAMEORIGIN
P3P: CP=None
Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
Access-Control-Allow-Headers: X-Requested-With,Content-Type
Access-Control-Allow-Credentials: true
Date: Fri, 10 Nov 2017 16:02:26 GMT
Các bước tái tạo
Kết quả thực tế
Traceback [most recent call last]:
File "", line 1, in
File "xxxxx/TestVirtualEnv/local/lib/python2.7/site-packages/requests/api.py", line 72, in get
return request['get', url, params=params, **kwargs]
File "xxxxx/TestVirtualEnv/local/lib/python2.7/site-packages/requests/api.py", line 58, in request
return session.request[method=method, url=url, **kwargs]
File "xxxxx/TestVirtualEnv/local/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
resp = self.send[prep, **send_kwargs]
File "xxxxx/TestVirtualEnv/local/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
r = adapter.send[request, **kwargs]
File "xxxxx/TestVirtualEnv/local/lib/python2.7/site-packages/requests/adapters.py", line 506, in send
raise SSLError[e, request=request]
requests.exceptions.SSLError: HTTPSConnectionPool[host='nlybstqvp4nb75n.code1.emi.philips.com', port=44300]: Max retries exceeded with url: / [Caused by SSLError[SSLError["bad handshake: Error[[['SSL routines', 'tls_process_server_certificate', 'certificate verify failed']],]",],]]
Các bước tái tạo
Thông tin hệ thốngThông tin hệ thống
$ python -m requests.help
{
"chardet": {
"version": "3.0.4"
},
"cryptography": {
"version": "2.1.3"
},
"idna": {
"version": "2.6"
},
"implementation": {
"name": "CPython",
"version": "2.7.12"
},
"platform": {
"release": "4.10.0-38-generic",
"system": "Linux"
},
"pyOpenSSL": {
"openssl_version": "1010007f",
"version": "17.3.0"
},
"requests": {
"version": "2.18.4"
},
"system_ssl": {
"version": "1000207f"
},
"urllib3": {
"version": "1.22"
},
"using_pyopenssl": true
}
Lỗi bắt tay xấu là gì?
please provide some basic information about your system [Python version,
operating system, &c].
Lỗi bắt tay xấu là gì?
Điều gì gây ra lỗi chứng chỉ SSL Python?an error message that occurs when the client or server wasn't able to establish a secure connection. This might occur if: The client is using the wrong date or time.
Điều gì gây ra lỗi chứng chỉ SSL Python?
Một giải pháp/giải thích sẽ rất tuyệt, cảm ơn!outdated Python default certificates or invalid root certificates. If you're a website owner and you're receiving this error, it could be because you're not using a valid SSL certificate.
Giấy chứng nhận xác minh có nghĩa là gì?
Chứng chỉ lỗi Ruby OpenSSL Xác minh không thành công có nghĩa là mã của bạn không thể xác minh rằng chứng chỉ SSL của Trang web hoặc API mà bạn đang kết nối là thật.Điều quan trọng là phải giải quyết vấn đề này một cách chính xác để giữ an toàn cho giao tiếp của bạn.your code can't verify that the SSL certificate of the website or API you're connecting to is the real one. It's important to solve this issue correctly to keep your communication secure.your code can't verify that the SSL certificate of the website or API you're connecting to is the real one. It's important to solve this issue correctly to keep your communication secure.
Yêu cầu Python có sử dụng HTTPS không?
Yêu cầu xác minh chứng chỉ SSL cho các yêu cầu HTTPS, giống như trình duyệt web., just like a web browser., just like a web browser.