Cố gắng thực hiện 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 SSLerror cho một trang web cụ thể. Tôi nghĩ rằng có lẽ vấn đề là với trang web (tôi đã thực hiện quét bằng cách sử dụng https://www.ssllabs.com, kết quả là xuống dưới), 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.Yêu cầu Python nhận SSLerror
Giải pháp/giải thích sẽ tuyệt vời, cảm ơn!
Mã:
import requests
requests.get('https://www.reporo.com/')
Tôi nhận được lỗi sau:
SSLError: [Errno bad handshake] [('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')]
---------------------------------------------------------------------------
SSLError Traceback (most recent call last)
<ipython-input-7-cfc21b287fee> in <module>()
----> 1 requests.get('https://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')]
Tôi chạy một quét tại https://www.ssllabs.com và đã nhận như sau:
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
Các máy chủ được sử dụng chứng chỉ không hợp lệ, giống như báo cáo nói. Do đó, 'yêu cầu' từ chối kết nối, vì việc chuyển giao thông tin có thể không an toàn. – MattDMo
Tôi có thể sử dụng cách giải quyết khác không? –