File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 pass
1414
1515from errno import EAGAIN , ECONNRESET , ETIMEDOUT
16- from ssl import SSLContext , create_default_context
1716from sys import implementation
1817from time import monotonic , sleep
1918from traceback import print_exception
3433from .route import Route
3534from .status import BAD_REQUEST_400 , FORBIDDEN_403 , NOT_FOUND_404 , UNAUTHORIZED_401
3635
37- if implementation .name != "circuitpython" :
38- from ssl import CERT_NONE , Purpose , SSLError
36+ try :
37+ from ssl import SSLContext , create_default_context
38+
39+ try : # ssl imports for C python
40+ from ssl import (
41+ CERT_NONE ,
42+ Purpose ,
43+ SSLError ,
44+ )
45+ except ImportError :
46+ pass
47+ SSL_AVAILABLE = True
48+ except ImportError :
49+ SSL_AVAILABLE = False
3950
4051
4152NO_REQUEST = "no_request"
@@ -129,6 +140,8 @@ def __init__(
129140 self .https = https
130141
131142 if https :
143+ if not SSL_AVAILABLE :
144+ raise NotImplementedError ("SSL not available on this platform" )
132145 self ._validate_https_cert_provided (certfile , keyfile )
133146 self ._ssl_context = self ._create_ssl_context (certfile , keyfile )
134147 else :
You can’t perform that action at this time.
0 commit comments