ca file debug

This commit is contained in:
Jerome Doucerain
2022-06-29 19:33:27 -04:00
parent 5b77520719
commit 79c0a676c5
+5 -1
View File
@@ -77,18 +77,22 @@ func ConnectTLS(ldapconfig LdapConfig) (*ldap.Conn, error) {
}
if ldapconfig.CA != "" {
log.Printf("CA file %s",ldapconfig.CA)
certpool := x509.NewCertPool()
CAfile, err := ioutil.ReadFile(ldapconfig.CA)
if err != nil {
log.Printf("Ldap CA file error")
return nil, fmt.Errorf("Ldap CA file error")
}
certpool.AppendCertsFromPEM([]byte(CAfile))
tlsConf = &tls.Config{RootCAs: certpool}
log.Printf("CA file %s loaded", ldapconfig.CA)
}
l, err := ldap.DialTLS("tcp", ldapconfig.Url, tlsConf)
if err != nil {
return nil, err
log.Printf("TLS error: %s", err)
return nil, err
}
return l, nil