tls still not working
This commit is contained in:
10
main.go
10
main.go
@ -8,6 +8,7 @@ import "strings"
|
|||||||
// import "time"
|
// import "time"
|
||||||
import MQTT "github.com/eclipse/paho.mqtt.golang"
|
import MQTT "github.com/eclipse/paho.mqtt.golang"
|
||||||
import "github.com/google/uuid"
|
import "github.com/google/uuid"
|
||||||
|
import "crypto/tls"
|
||||||
|
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
@ -93,6 +94,15 @@ func startMqttClient() MQTT.Client {
|
|||||||
opts.SetPassword(password)
|
opts.SetPassword(password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableTls := os.Getenv("MQTT_ENABLE_TLS")
|
||||||
|
if enableTls == "true" {
|
||||||
|
log.Println("Enableing TLS connection")
|
||||||
|
tlsConfig := &tls.Config {
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}
|
||||||
|
opts.SetTLSConfig(tlsConfig)
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("Trying to connect to broker")
|
log.Println("Trying to connect to broker")
|
||||||
client := MQTT.NewClient(opts)
|
client := MQTT.NewClient(opts)
|
||||||
if token := client.Connect(); token.Wait() && token.Error() != nil {
|
if token := client.Connect(); token.Wait() && token.Error() != nil {
|
||||||
|
Reference in New Issue
Block a user