mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 11:51:16 -06:00
Error out if LDAP CA cert is not valid
If the configured LDAP CA cert can not be successfully loaded to the Pool let the creation of the Graph Service fail.
This commit is contained in:
@@ -59,6 +59,10 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
svc.EventsPublisher(publisher),
|
||||
)
|
||||
|
||||
if handle == nil {
|
||||
return http.Service{}, errors.New("could not initialize graph service")
|
||||
}
|
||||
|
||||
{
|
||||
handle = svc.NewInstrument(handle, options.Metrics)
|
||||
handle = svc.NewLogging(handle, options.Logger)
|
||||
|
||||
@@ -106,10 +106,13 @@ func NewService(opts ...Option) Service {
|
||||
certs := x509.NewCertPool()
|
||||
pemData, err := ioutil.ReadFile(options.Config.Identity.LDAP.CACert)
|
||||
if err != nil {
|
||||
options.Logger.Error().Msgf("Error initializing LDAP Backend: '%s'", err)
|
||||
options.Logger.Error().Err(err).Msgf("Error initializing LDAP Backend")
|
||||
return nil
|
||||
}
|
||||
if !certs.AppendCertsFromPEM(pemData) {
|
||||
options.Logger.Error().Msgf("Error initializing LDAP Backend. Adding CA cert failed")
|
||||
return nil
|
||||
}
|
||||
certs.AppendCertsFromPEM(pemData)
|
||||
tlsConf.RootCAs = certs
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user