Skip to content

Commit 3f0cc8b

Browse files
author
clickingbuttons
authored
add certifi for wss (#156)
* add certifi for wss * lint
1 parent 2a49fdf commit 3f0cc8b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

polygon/websocket/__init__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
22
from enum import Enum
33
from typing import Optional, Union, List, Set, Callable, Awaitable
4+
import json
5+
import inspect
6+
import ssl
7+
import certifi
48
from .models import *
59
from websockets.client import connect, WebSocketClientProtocol
610
from websockets.exceptions import ConnectionClosedOK, ConnectionClosedError
711
from websockets.typing import Data
8-
import json
9-
import inspect
1012

1113
env_key = "POLYGON_API_KEY"
1214

@@ -74,7 +76,12 @@ async def connect(
7476
isasync = inspect.iscoroutinefunction(processor)
7577
if self.verbose:
7678
print("connect:", self.url)
77-
async for s in connect(self.url, close_timeout=close_timeout, **kwargs):
79+
# darwin needs some extra <3
80+
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
81+
ssl_context.load_verify_locations(certifi.where())
82+
async for s in connect(
83+
self.url, close_timeout=close_timeout, ssl=ssl_context, **kwargs
84+
):
7885
self.websocket = s
7986
try:
8087
msg = await s.recv()

0 commit comments

Comments
 (0)