0

用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客户端里是可以连接上的

2019-09-16 提问
0 个回答

撰写答案

推广链接