Skip to content

Commit 52d52df

Browse files
committed
Revert "Add check for builtin ssl module"
This reverts commit 153090b.
1 parent 790ce5f commit 52d52df

File tree

2 files changed

+13
-62
lines changed

2 files changed

+13
-62
lines changed

adafruit_azureiot/device_registration.py

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
1212
1313
* Author(s): Jim Bennett, Elena Horton
1414
"""
15-
SSL_MODULE = True
1615

1716
import json
17+
import ssl
1818
import time
19-
try:
20-
import ssl
21-
except:
22-
SSL_MODULE = False
2319

2420
import adafruit_logging as logging
2521
from adafruit_logging import Logger
@@ -55,9 +51,6 @@ def __init__(
5551
device_id: str,
5652
device_sas_key: str,
5753
logger: Logger = None,
58-
device_certificate = None,
59-
private_certificate_key = None,
60-
use_builtin_ssl_module = True
6154
):
6255
"""Creates an instance of the device registration service
6356
@@ -84,10 +77,6 @@ def __init__(
8477
self._socket = socket
8578
self._iface = iface
8679

87-
self._device_certificate = device_certificate
88-
self._private_certificate_key = private_certificate_key
89-
self._use_builtin_ssl_module = use_builtin_ssl_module
90-
9180
# pylint: disable=W0613
9281
# pylint: disable=C0103
9382
def _on_connect(self, client, userdata, _, rc) -> None:
@@ -207,28 +196,15 @@ def register_device(self, expiry: int) -> str:
207196

208197
MQTT.set_socket(self._socket, self._iface)
209198

210-
if self._use_builtin_ssl_module and SSL_MODULE:
211-
self._mqtt = MQTT.MQTT(
212-
broker=constants.DPS_END_POINT,
213-
username=username,
214-
password=auth_string,
215-
port=8883,
216-
keep_alive=120,
217-
client_id=self._device_id,
218-
ssl_context=ssl.create_default_context(),
219-
)
220-
else:
221-
if self._device_certificate is not None:
222-
self.iface.set_certificate(self._device_certificate)
223-
self.iface.set_private_key(self._private_certificate_key)
224-
self._mqtt = MQTT.MQTT(
225-
broker=constants.DPS_END_POINT,
226-
username=username,
227-
password=auth_string,
228-
port=8883,
229-
keep_alive=120,
230-
client_id=self._device_id
231-
)
199+
self._mqtt = MQTT.MQTT(
200+
broker=constants.DPS_END_POINT,
201+
username=username,
202+
password=auth_string,
203+
port=8883,
204+
keep_alive=120,
205+
client_id=self._device_id,
206+
ssl_context=ssl.create_default_context(),
207+
)
232208

233209
self._mqtt.enable_logger(logging, self._logger.getEffectiveLevel())
234210

adafruit_azureiot/iot_mqtt.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@
1212
* Author(s): Jim Bennett, Elena Horton
1313
"""
1414

15-
SSL_MODULE = True
16-
1715
import gc
1816
import json
17+
import ssl
1918
import time
20-
try:
21-
import ssl
22-
except:
23-
SSL_MODULE = False
2419

2520
import adafruit_minimqtt.adafruit_minimqtt as MQTT
2621
import adafruit_logging as logging
@@ -137,28 +132,15 @@ def _create_mqtt_client(self) -> None:
137132
)
138133
)
139134

140-
if self._use_builtin_ssl_module and SSL_MODULE:
141-
self._mqtt = MQTT.MQTT(
135+
self._mqtts = MQTT.MQTT(
142136
broker=self._hostname,
143137
username=self._username,
144138
password=self._passwd,
145139
port=8883,
146140
keep_alive=120,
147141
client_id=self._device_id,
148142
ssl_context=ssl.create_default_context(),
149-
)
150-
else:
151-
if self._device_certificate is not None:
152-
self.iface.set_certificate(self._device_certificate)
153-
self.iface.set_private_key(self._private_certificate_key)
154-
self._mqtt = MQTT.MQTT(
155-
broker=self._hostname,
156-
username=self._username,
157-
password=self._passwd,
158-
port=8883,
159-
keep_alive=120,
160-
client_id=self._device_id
161-
)
143+
)
162144

163145
self._mqtts.enable_logger(logging, self._logger.getEffectiveLevel())
164146

@@ -350,9 +332,6 @@ def __init__(
350332
device_sas_key: str,
351333
token_expires: int = 21600,
352334
logger: Logger = None,
353-
device_certificate = None,
354-
private_certificate_key = None,
355-
use_builtin_ssl_module = True
356335
):
357336
"""Create the Azure IoT MQTT client
358337
@@ -386,10 +365,6 @@ def __init__(
386365
self._logger.addHandler(logging.StreamHandler())
387366
self._is_subscribed_to_twins = False
388367

389-
self._device_certificate = device_certificate
390-
self._private_certificate_key = private_certificate_key
391-
self._use_builtin_ssl_module = use_builtin_ssl_module
392-
393368
def _subscribe_to_core_topics(self):
394369
device_bound_topic = "devices/{}/messages/devicebound/#".format(self._device_id)
395370
self._mqtts.add_topic_callback(

0 commit comments

Comments
 (0)