mirror of https://github.com/h44z/wg-portal.git
				
				
				
			disable cert-check should also work for ldap via ssl (#12)
This commit is contained in:
		
							parent
							
								
									28c2494d88
								
							
						
					
					
						commit
						e65a4a8148
					
				|  | @ -16,14 +16,15 @@ type RawLdapData struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func Open(cfg *Config) (*ldap.Conn, error) { | func Open(cfg *Config) (*ldap.Conn, error) { | ||||||
| 	conn, err := ldap.DialURL(cfg.URL) | 	tlsConfig := &tls.Config{InsecureSkipVerify: !cfg.CertValidation} | ||||||
|  | 	conn, err := ldap.DialURL(cfg.URL, ldap.DialWithTLSConfig(tlsConfig)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, errors.Wrap(err, "failed to connect to LDAP") | 		return nil, errors.Wrap(err, "failed to connect to LDAP") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if cfg.StartTLS { | 	if cfg.StartTLS { | ||||||
| 		// Reconnect with TLS
 | 		// Reconnect with TLS
 | ||||||
| 		err = conn.StartTLS(&tls.Config{InsecureSkipVerify: !cfg.CertValidation}) | 		err = conn.StartTLS(tlsConfig) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, errors.Wrap(err, "failed to star TLS on connection") | 			return nil, errors.Wrap(err, "failed to star TLS on connection") | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue