fixed log format for MongoDB, and tls config
This commit is contained in:
parent
e2c3930ebf
commit
17c5f1e372
|
@ -1276,7 +1276,7 @@ Options for `mongo` are the following:
|
|||
| auth_opt_mongo_acls | acls | N | ACL collection |
|
||||
| auth_opt_mongo_disable_superuser | true | N | Disable query to check for superuser |
|
||||
| auth_opt_mongo_insecure_skip_verify | false | N | Verify server's certificate chain |
|
||||
| auth_opt_mongo_tls | false | N | Connect with TLS |
|
||||
| auth_opt_mongo_with_tls | false | N | Connect with TLS |
|
||||
| auth_opt_mongo_tlsca | "" | N | TLS Certificate Authority (CA) |
|
||||
| auth_opt_mongo_tlscert | "" | N | TLS Client Certificate |
|
||||
| auth_opt_mongo_tlskey | "" | N | TLS Client Certificate Private Key |
|
||||
|
|
|
@ -114,7 +114,7 @@ func NewMongo(authOpts map[string]string, logLevel log.Level, hasher hashing.Has
|
|||
|
||||
useTlsClientCertificate := false
|
||||
|
||||
if authOpts["mongo_tls"] == "true" {
|
||||
if authOpts["mongo_with_tls"] == "true" {
|
||||
m.withTLS = true
|
||||
}
|
||||
|
||||
|
@ -143,23 +143,28 @@ func NewMongo(authOpts map[string]string, logLevel log.Level, hasher hashing.Has
|
|||
}
|
||||
|
||||
if m.withTLS {
|
||||
log.Infof("mongo backend: tls enabled")
|
||||
log.Info("mongo backend: tls enabled")
|
||||
opts.TLSConfig = &tls.Config{
|
||||
InsecureSkipVerify: m.insecureSkipVerify,
|
||||
}
|
||||
|
||||
if useTlsClientCertificate {
|
||||
caCert, err := os.ReadFile(m.TLSCa)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("mongo backend: tls error: %s", err)
|
||||
}
|
||||
|
||||
caCertPool := x509.NewCertPool()
|
||||
if ok := caCertPool.AppendCertsFromPEM(caCert); !ok {
|
||||
log.Errorf("mongo backend: tls error: CA file must be in PEM format")
|
||||
log.Error("mongo backend: tls error: CA file must be in PEM format")
|
||||
}
|
||||
|
||||
cert, err := tls.LoadX509KeyPair(m.TLSCert, m.TLSKey)
|
||||
if err != nil {
|
||||
log.Errorf("mongo backend: tls error: %s", err)
|
||||
}
|
||||
|
||||
opts.TLSConfig = &tls.Config{
|
||||
RootCAs: caCertPool,
|
||||
Certificates: []tls.Certificate{cert},
|
||||
|
|
Loading…
Reference in New Issue