Skip to content

Commit

Permalink
Merge pull request dexidp#1278 from veily/master
Browse files Browse the repository at this point in the history
Support used self-signed certificates LDAP.
  • Loading branch information
srenatus authored Sep 22, 2018
2 parents 3d08890 + 94cb333 commit 5234715
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions connector/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ type Config struct {

// Path to a trusted root certificate file.
RootCA string `json:"rootCA"`

// Path to a client cert file generated by rootCA.
ClientCert string `json:"clientCert"`
// Path to a client private key file generated by rootCA.
ClientKey string `json:"clientKey"`
// Base64 encoded PEM data containing root CAs.
RootCAData []byte `json:"rootCAData"`

Expand Down Expand Up @@ -104,7 +107,6 @@ type Config struct {
IDAttr string `json:"idAttr"` // Defaults to "uid"
EmailAttr string `json:"emailAttr"` // Defaults to "mail"
NameAttr string `json:"nameAttr"` // No default.

} `json:"userSearch"`

// Group search configuration.
Expand Down Expand Up @@ -226,6 +228,14 @@ func (c *Config) openConnector(logger logrus.FieldLogger) (*ldapConnector, error
}
tlsConfig.RootCAs = rootCAs
}

if c.ClientKey != "" && c.ClientCert != "" {
cert, err := tls.LoadX509KeyPair(c.ClientCert, c.ClientKey)
if err != nil {
return nil, fmt.Errorf("ldap: load client cert failed: %v", err)
}
tlsConfig.Certificates = append(tlsConfig.Certificates, cert)
}
userSearchScope, ok := parseScope(c.UserSearch.Scope)
if !ok {
return nil, fmt.Errorf("userSearch.Scope unknown value %q", c.UserSearch.Scope)
Expand Down

0 comments on commit 5234715

Please sign in to comment.