支持设置根证书校验服务端
This commit is contained in:
parent
425e9f1c5a
commit
38a986634c
|
@ -657,12 +657,16 @@ func (device *iotDevice) Init() bool {
|
||||||
if strings.Contains(device.Servers, "tls") || strings.Contains(device.Servers, "ssl") {
|
if strings.Contains(device.Servers, "tls") || strings.Contains(device.Servers, "ssl") {
|
||||||
glog.Infof("server support tls connection")
|
glog.Infof("server support tls connection")
|
||||||
if device.ServerCert != nil {
|
if device.ServerCert != nil {
|
||||||
certPool:=x509.NewCertPool()
|
certPool := x509.NewCertPool()
|
||||||
certPool.AppendCertsFromPEM(device.ServerCert)
|
certPool.AppendCertsFromPEM(device.ServerCert)
|
||||||
options.SetTLSConfig(&tls.Config{
|
options.SetTLSConfig(&tls.Config{
|
||||||
RootCAs: certPool,
|
RootCAs: certPool,
|
||||||
InsecureSkipVerify: false,
|
InsecureSkipVerify: false,
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
options.SetTLSConfig(&tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options.SetTLSConfig(&tls.Config{
|
options.SetTLSConfig(&tls.Config{
|
||||||
|
|
Loading…
Reference in New Issue