1.13.5 SSL Certificate Errors
Upon updating to 1.13.5, I started receiving SSL certificate errors. I rolled back to 1.13.4 and the error went away. I see there were changes made to SSL and HTTPS in the new version. Error printout below
Traceback (most recent call last):
File D:\anaconda\Lib\site-packages\urllib3\connectionpool.py:715 in urlopen
httplib_response = self._make_request(
File D:\anaconda\Lib\site-packages\urllib3\connectionpool.py:404 in _make_request
self._validate_conn(conn)
File D:\anaconda\Lib\site-packages\urllib3\connectionpool.py:1058 in _validate_conn
conn.connect()
File D:\anaconda\Lib\site-packages\urllib3\connection.py:419 in connect
self.sock = ssl_wrap_socket(
File D:\anaconda\Lib\site-packages\urllib3\util\ssl_.py:449 in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File D:\anaconda\Lib\site-packages\urllib3\util\ssl_.py:493 in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File D:\anaconda\Lib\ssl.py:517 in wrap_socket
return self.sslsocket_class._create(
File D:\anaconda\Lib\ssl.py:1108 in _create
self.do_handshake()
File D:\anaconda\Lib\ssl.py:1383 in do_handshake
self._sslobj.do_handshake()
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)
Thanks for reporting @pondscum1997. I'll see if I can reproduce. Looks like you're on a Windows machine -- can you give me the version? I'll try to test it.
Thanks for reporting @pondscum1997. I'll see if I can reproduce. Looks like you're on a Windows machine -- can you give me the version? I'll try to test it.
I apologize in advance for not being the most up to date user, I'm running Microsoft Windows 10 Education Version 10.0.19045 Build 19045. I noticed I was running this on Spyder 5.4.3, just updated to 5.5.1 and its the same.
- Spyder version: 5.5.1 (conda)
- Python version: 3.11.7 64-bit
- Qt version: 5.15.2
- PyQt5 version: 5.15.10
- Operating System: Windows-10-10.0.19045-SP0
Ah, no need to apologize. I just wanted to make sure I was running something close enough to debug it. You're all good. Thanks for getting back to me. I'll check it out.
Hey @pondscum1997, I'm still checking this out and cannot reproduce it.
Do you mind updating your urllib3 and certifi libraries? Probably with something like:
pip install -U urllib3
pip install -U certifi
Maybe you could try adding some additional code around the API call to see if we can see what cert it is complaining about.
try:
# Your code that triggers the SSL error
except ssl.SSLCertVerificationError as e:
logger.error(f"SSL certificate verification failed: {e}")
# You can add more detailed logging here, such as:
logger.debug(f"Certificate verify failed due to: {e.reason}. Verification process: {e.verify_code}")
Was is just happening on a simple rest API call? Sorry, I know it's a pain to install the other version and test. I just wanted to try and figure out what the root cause is here.
Sorry for the delay, everything was updated and still the same fault. I was running something similar to this.
from polygon import RESTClient
from polygon.rest import models
client = RESTClient()
aggs = client.get_aggs(
"AAPL",
1,
"day",
"2022-04-04",
"2022-04-04",
)
print(aggs)
Again, this works on 1.13.4 but not 1.13.5. It also isn't logging the error like I want it to, so I'll get back to you on that once I figure that part out.
Okay, thanks for your help here @pondscum1997. I really appreciate the help. Does this happen to be a work computer or anything where you might have security software installed? I'm just wondering if there is an ssl proxy or something. Or, is it just a normal desktop system?
@justinpolygon This is a regular at home desktop. I'm going to install OpenSSL to try and troubleshoot better.
Hi guys, I am having the same type of issue. I am not sure about the versions but I am getting the same type of SSL related error on a basic 'get_agg()' command.
error message goes something like this: . . . File "C:\Users\username\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\retry.py", line 519, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.polygon.io', port=443): Max retries exceeded with url: /v2/aggs/ticker/AAPL/range/1/day/2022-01-01/2024-06-21 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)'))) PS C:\Python Projects>
I am using: Python 3.11.5, Windows 11 64-bit, VS Code editor.
@pondscum1997 & @Zinaction do you mind testing this again using the v1.14.0 release to see if that fixes it?
You can upgrade via pip install -U polygon-api-client.
@justinpolygon I updated via 'pip install -U polygon-api-client' and I still get the same error. If this helps: I tried the same 'client.get_aggs()' command in a Google Collab notebook and I did not get any errors.
hi,
I had the same issue with 1.14.0 version. After taking this https://github.com/polygon-io/client-python/pull/691 solution, it worked a gain.
Hi @pondscum1997 and @Zinaction we've released a new version https://github.com/polygon-io/client-python/releases/tag/v1.14.1 that should fix the issue going forward. What happened was the added a optimization for caching ssl certificates and that inadvertently caused issues for Windows systems. Sorry for the inconvenience here and thanks for working with us while we figured out what was going on.
FYI - I'm going to close this since I have verified it's fixed. But, feel free to re-open if something pops up. Thanks again for all the help here.
polygon-api-client-1.14.1 fixed my issue and now the '.get_aggs()' command returns data. Thank you for the update.