File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -115,17 +115,7 @@ def connect(self):
115115 self .__mqtt .on_connect = self .__onConnect
116116 self .__mqtt .on_message = self .__onMessage
117117 if self .__port == SSL :
118- filename = "/etc/ssl/certs/ca-certificates.crt"
119-
120- if self .__board .get_os_id () == LiveObjects .BoardsInterface .WINDOWS :
121- try :
122- import certifi
123- filename = certifi .where ()
124- except ImportError :
125- print ("[ERROR] U have missing library 'python-certifi-win32'" )
126- sys .exit ()
127-
128- self .__mqtt .tls_set (filename )
118+ self .__mqtt .tls_set (self .__board .get_store_cert_filename ())
129119 self .__mqtt .connect (self .__server , self .__port , 60 )
130120 self .__mqtt .loop_start ()
131121 elif self .mode == LiveObjects .BoardsInterface .MICROPYTHON :
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ def get_os_id(self):
4848 def get_security_level (self ):
4949 pass
5050
51+ def get_store_cert_filename (self ):
52+ pass
53+
5154 def check_network_capabilities (self , net_type ):
5255 if net_type not in self ._carrier_capability :
5356 print ('Carrier not supported.' )
@@ -122,6 +125,14 @@ def get_security_level(self):
122125 def get_os_id (self ):
123126 return self ._os_id
124127
128+ def get_store_cert_filename (self ):
129+ try :
130+ import certifi
131+ return certifi .where ()
132+ except ImportError :
133+ print ("[ERROR] U have missing library 'python-certifi-win32'" )
134+ sys .exit ()
135+
125136
126137class Esp32 (BoardsInterface ):
127138 def __init__ (self , net_type ):
@@ -147,6 +158,7 @@ def __init__(self, net_type):
147158 self ._carrier_capability = (BoardsInterface .EXISTING_NETWORK ,)
148159 self ._existing_network_tls_capability = True
149160 self ._credentials = super ().create_credentials (self ._net_type )
161+ self ._cert_store_filename = "/etc/ssl/certs/ca-certificates.crt"
150162
151163 def connect (self ):
152164 super ().check_network_capabilities (self ._net_type )
@@ -158,6 +170,9 @@ def get_security_level(self):
158170 def get_os_id (self ):
159171 return self ._os_id
160172
173+ def get_store_cert_filename (self ):
174+ return self ._cert_store_filename
175+
161176
162177class BoardsFactory :
163178
You can’t perform that action at this time.
0 commit comments