mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-13 11:23:40 +00:00
Make TLS work over WiFiNINA
Verified on Arduino Nano33 IoT and nina fw v1.4.5
This commit is contained in:
+6
-2
@@ -4,6 +4,7 @@ package tls
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"tinygo.org/x/drivers/net"
|
||||
)
|
||||
@@ -17,14 +18,17 @@ func Dial(network, address string, config *Config) (*net.TCPSerialConn, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addr := raddr.IP.String()
|
||||
hostname := strings.Split(address, ":")[0]
|
||||
sendport := strconv.Itoa(raddr.Port)
|
||||
if sendport == "0" {
|
||||
sendport = "443"
|
||||
}
|
||||
|
||||
// disconnect any old socket
|
||||
net.ActiveDevice.DisconnectSocket()
|
||||
|
||||
// connect new socket
|
||||
err = net.ActiveDevice.ConnectSSLSocket(addr, sendport)
|
||||
err = net.ActiveDevice.ConnectSSLSocket(hostname, sendport)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user