Skip to content

1.13.5 SSL Certificate Errors #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pondscum1997 opened this issue Apr 9, 2024 · 14 comments
Closed

1.13.5 SSL Certificate Errors #638

pondscum1997 opened this issue Apr 9, 2024 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@pondscum1997
Copy link

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)
@pondscum1997 pondscum1997 added the bug Something isn't working label Apr 9, 2024
@justinpolygon
Copy link
Contributor

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.

@justinpolygon justinpolygon self-assigned this Apr 9, 2024
@pondscum1997
Copy link
Author

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

@justinpolygon
Copy link
Contributor

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.

@justinpolygon
Copy link
Contributor

justinpolygon commented Apr 10, 2024

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.

@pondscum1997
Copy link
Author

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.

@justinpolygon
Copy link
Contributor

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?

@pondscum1997
Copy link
Author

@justinpolygon This is a regular at home desktop. I'm going to install OpenSSL to try and troubleshoot better.

@zunleashed
Copy link

zunleashed commented Jun 22, 2024

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.

@justinpolygon
Copy link
Contributor

@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.

@zunleashed
Copy link

zunleashed commented Jul 2, 2024

@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.

@yy824
Copy link

yy824 commented Jul 2, 2024

hi,

I had the same issue with 1.14.0 version. After taking this #691 solution, it worked a gain.

@justinpolygon
Copy link
Contributor

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.

@justinpolygon
Copy link
Contributor

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.

@zunleashed
Copy link

polygon-api-client-1.14.1 fixed my issue and now the '.get_aggs()' command returns data. Thank you for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants