用oneNet的mqtt, 需要ca.pem的证书, 但这样还是连接不上
pool := x509.NewCertPool()
caCertPath := "./MQTTS-certificate.pem"
caCrt, err := ioutil.ReadFile(caCertPath)
if err != nil {
fmt.Println("ReadFile err:", err)
return
}
pool.AppendCertsFromPEM(caCrt)
config := &tls.Config{
RootCAs: pool,
MaxVersion: tls.VersionTLS12,
MinVersion: tls.VersionTLS12,
}
conn, err := tls.Dial("tcp", "183.230.40.16:8883", config)
if err != nil {
panic(err)
}
panic: x509: cannot validate certificate for 183.230.40.16 because it doesn't contain any IP SANs Connection Refused: unacceptable protocol version
同样的认证信息在mqtt.fx客户端里是可以连接上的