Skip to content

Commit 3cc82bc

Browse files
Improve documentation for tLSClientConfig
1 parent 2f9e362 commit 3cc82bc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

controllers/database.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ var mariadbTemplates = []string{
4747
"mariadb/default/tls-config.yaml.tmpl",
4848
}
4949

50+
// tLSClientConfig creates and returns a TLS client configuration that includes
51+
// a set of custom CA certificates for secure communication. It reads CA
52+
// certificates from the environment variable `SSL_CERT_FILE` if it is set,
53+
// and appends any additional certificates passed as input.
54+
//
55+
// Parameters:
56+
//
57+
// pems [][]byte: PEM-encoded certificates to be appended to the
58+
// root certificate pool.
59+
//
60+
// Returns:
61+
//
62+
// *cryptoTls.Config: A TLS configuration with the certificates set to the updated
63+
// certificate pool.
64+
// error: An error if there is a failure in parsing any of the provided PEM
65+
// certificates, or nil if successful.
5066
func tLSClientConfig(pems [][]byte) (*cryptoTls.Config, error) {
5167
rootCertPool := x509.NewCertPool()
5268

@@ -120,7 +136,6 @@ var ConnectAndQueryDatabase = func(
120136
// don't set anything
121137
case "true":
122138
var err error
123-
// if pemCerts is empty, that is OK, we still add OS certs to the tls config
124139
tlsConfig, err = tLSClientConfig(pemCerts)
125140
if err != nil {
126141
log.Info(fmt.Sprintf("Encountered error when processing custom ca bundle, Error: %v", err))

0 commit comments

Comments
 (0)