MQTT for Tcl

View Ticket
Login
Ticket Hash: 3f256a209be15235548fc36e7e44ca047ea13a0d
Title: TLS Support
Status: Closed Type: Feature_Request
Severity: Important Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2020-10-24 08:24:25
Version Found In: 1.1
User Comments:
anonymous added on 2018-05-14 14:14:48:
The following patch enables support for TLS connections through the provision of a new configuration option called -socketcmd. The option should be a list, this list will be automatically added -async and the host and port of the remote server whenever a connection to the remote server is to be established. Thus setting this options to something in the line of ::tls::socket -ssl3 0 -ssl2 0 -tls1 1 -tls1.1 1 -tls1.2 1 (or whatever applies to your local installation), would arrange for a TLS connection to the remote MQTT server.

Feel free to merge:

--- mqtt-1.1.tcl	2018-05-14 15:55:57.649878050 +0200
+++ mqtt.tcl	2018-05-14 15:54:14.773541990 +0200
@@ -19,8 +19,9 @@
 	    -retransmit		5000
 	    -username		""
 	    -password		""
-	    -clean		1
+	    -clean		    1
 	    -protocol		4
+        -socketcmd      {socket}
 	}
 	variable fd "" data "" queue {} connect {} coro "" events {}
 	variable keepalive [expr {[dict get $config -keepalive] * 1000}]
@@ -349,7 +350,7 @@
 	    return 0
 	}
 	log "Connecting to $host on port $port"
-	if {[catch {socket -async $host $port} sock]} {
+	if {[catch {{*}[my configure -socketcmd] -async $host $port} sock]} {
 	    log "Connection failed: $sock"
 	    return 0
 	}

schelte added on 2018-05-19 12:31:18:

Thanks. That looks like a simple and useful addition.


schelte added on 2020-10-24 08:24:25:

Implemented by check-in [60f7dad461] (2018-05-20)