SSL Handshare Errors - RebelCoder - Apr-07-2019
Hello everyone!
I am trying to access some DB with requests, and this code worked about a month ago:
print(f"\n[Protein function based on www.uniprot.org DB]:")
protein_db = {}
with open("materials/protein_db.txt", 'r') as f:
for line in f:
protein_db[line[-11:-5]] = line.strip()
pattern = re.compile(r'\bP:(.*);')
for protein, url in protein_db.items():
protein_db = requests.get(url, timeout=20)
result = pattern.finditer(protein_db.text) But now fails and shows the following error:
Error: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 453, in wrap_socket
cnx.do_handshake()
File "/home/jurisl/.local/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/home/jurisl/.local/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1647, in _raise_ssl_error
_raise_current_error()
File "/home/jurisl/.local/lib/python3.7/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 841, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 344, in connect
ssl_context=context)
File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 459, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])",)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.uniprot.org', port=443): Max retries exceeded with url: /uniprot/B5ZC00.txt (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])")))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/media/Work/Work/Rosalind/bio_armory.py", line 23, in <module>
protein_db = requests.get(url, timeout=20)
File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.uniprot.org', port=443): Max retries exceeded with url: /uniprot/B5ZC00.txt (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')])")))
I found that I needed the following libs, pip-installed:
pyOpenSSL
ndg-httpsclient
pyasn1
Installing/re-installing them did not solve the issue.
Any ideas/suggestions ?
Regards.
RE: SSL Handshare Errors - kritesh - May-11-2019
When an SSL handshake fails, Error 525 occurs in Full or Full (Strict) SSL mode. This is typically caused by a configuration issue in the origin web server.If you are a site visitor, report the problem to the site owner. Cloudflare Support cannot assist you as we are only able to work with the verified owner of the domain.
To fix from SSl Connection. Follow these steps:
Check the Date of Your System. Date is the most common reason behind SSL errors.
Clear Browsing Data.
Clear Your SSL State.
Disable QUIC Protocol of Chrome.
Check Your Antivirus Settings.
Check Your Firewall.
Disable Extensions.
Adjust Your Internet Security and Privacy Level.
RE: SSL Handshare Errors - DeaD_EyE - May-11-2019
On my machine it works:
In [37]: requests.get('https://uniprot.org/uniprot/B5ZC00.txt')
Out[37]: <Response [200]> Maybe they have changed the configuration of the webserver or you have SSL problems.
Try to access to other pages (google or this one), which offers SSL Encryption and look if the same problem happens.
|