客户端tls证书不接受以----- BEGIN TRUSTED CERTIFICATE -----开头并以----- END TRUSTED CERTIFICATE -----结尾的证书

时间:2019-07-16 06:50:23

标签: go client-certificates

当我使用以----- BEGIN CERTIFICATE -----开头并以----- END CERTIFICATE -----结束的证书时,它可以正常工作,但是以----- BEGIN Trusted开头CERTIFICATE -----并以----- END TRUSTED CERTIFICATE -----结尾,它抛出错误,提示x509:未知授权机构签名的证书

go rest服务器在linux后台运行

func SetupTLS() {
       certs := x509.NewCertPool()
       if BackendServerCertificateFile == "" {
               if runtime.GOOS == "windows" {
                       BackendServerCertificateFile = filepath.Join(os.Getenv("PROGRAMFILES"), "/conf/ssl/trustedcert/SSCert.pem")
               } else {
                       BackendServerCertificateFile = "/conf/ssl/trustedcert/SSCert.pem"
               }
       }

       pemData, err := ioutil.ReadFile(BackendServerCertificateFile)
       if err != nil {
               event.LogEventError(err, nil)
               return
       }
       certs.AppendCertsFromPEM(pemData)
       var LDAPServerName string
       ldapServer_port := strings.Split(LDAPServer, ":")
       if len(ldapServer_port) >= 1 {
               LDAPServerName = ldapServer_port[0]
       }
       TlsConfig = &tls.Config{ServerName: LDAPServerName, RootCAs: certs}
}

这是我得到的错误“ x509:未知授权机构签名的证书”

0 个答案:

没有答案