Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98d0a2b

Browse files
committed
umqtt.simple: Restore legacy ssl/ssl_params arguments.
Commit35d41db changed the API for usingSSL with umqtt, but only did a minor version increase. This broke varioususes of this library, eghttps://github.com/aws-samples/aws-iot-core-getting-started-micropythonReinstate the original API for specifying an SSL connection. This librarynow supports the following:- default, ssl=None or ssl=False: no SSL- ssl=True and optional ssl_params specified: use ssl.wrap_socket- ssl=<SSLContext instance>: use provided SSL context to wrap socketSigned-off-by: Damien George <damien@micropython.org>
1 parent96e17b6 commit98d0a2b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
metadata(description="Lightweight MQTT client for MicroPython.",version="1.5.0")
1+
metadata(description="Lightweight MQTT client for MicroPython.",version="1.6.0")
22

33
# Originally written by Paul Sokolovsky.
44

5+
require("ssl")
6+
57
package("umqtt")

‎micropython/umqtt.simple/umqtt/simple.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(
1717
password=None,
1818
keepalive=0,
1919
ssl=None,
20+
ssl_params={},
2021
):
2122
ifport==0:
2223
port=8883ifsslelse1883
@@ -25,6 +26,7 @@ def __init__(
2526
self.server=server
2627
self.port=port
2728
self.ssl=ssl
29+
self.ssl_params=ssl_params
2830
self.pid=0
2931
self.cb=None
3032
self.user=user
@@ -65,7 +67,12 @@ def connect(self, clean_session=True, timeout=None):
6567
self.sock.settimeout(timeout)
6668
addr=socket.getaddrinfo(self.server,self.port)[0][-1]
6769
self.sock.connect(addr)
68-
ifself.ssl:
70+
ifself.sslisTrue:
71+
# Legacy support for ssl=True and ssl_params arguments.
72+
importssl
73+
74+
self.sock=ssl.wrap_socket(self.sock,**self.ssl_params)
75+
elifself.ssl:
6976
self.sock=self.ssl.wrap_socket(self.sock,server_hostname=self.server)
7077
premsg=bytearray(b"\x10\0\0\0\0\0")
7178
msg=bytearray(b"\x04MQTT\x04\x02\0\0")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp