File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 13
13
pass
14
14
15
15
from errno import EAGAIN , ECONNRESET , ETIMEDOUT
16
- from ssl import SSLContext , create_default_context
17
16
from sys import implementation
18
17
from time import monotonic , sleep
19
18
from traceback import print_exception
34
33
from .route import Route
35
34
from .status import BAD_REQUEST_400 , FORBIDDEN_403 , NOT_FOUND_404 , UNAUTHORIZED_401
36
35
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
39
50
40
51
41
52
NO_REQUEST = "no_request"
@@ -129,6 +140,8 @@ def __init__(
129
140
self .https = https
130
141
131
142
if https :
143
+ if not SSL_AVAILABLE :
144
+ raise NotImplementedError ("SSL not available on this platform" )
132
145
self ._validate_https_cert_provided (certfile , keyfile )
133
146
self ._ssl_context = self ._create_ssl_context (certfile , keyfile )
134
147
else :
You can’t perform that action at this time.
0 commit comments