in controllers/solrcloud_controller.go [1139:1183]
func (r *SolrCloudReconciler) reconcileTLSConfig(instance *solrv1beta1.SolrCloud) (*util.TLSCerts, error) {
tls := util.TLSCertsForSolrCloud(instance)
// Has the user configured a secret containing the TLS cert files that we need to mount into the Solr pods?
serverCert := tls.ServerConfig.Options
if serverCert.PKCS12Secret != nil {
// Ensure one or the other have been configured, but not both
if serverCert.MountedTLSDir != nil {
return nil, fmt.Errorf("invalid TLS config, either supply `solrTLS.pkcs12Secret` or `solrTLS.mountedTLSDir` but not both")
}
_, err := tls.ServerConfig.VerifyKeystoreAndTruststoreSecretConfig(&r.Client)
if err != nil {
return nil, err
}
// is there a client TLS config too?
if tls.ClientConfig != nil {
if tls.ClientConfig.Options.PKCS12Secret == nil {
// cannot mix options with the client cert, if the server cert comes from a secret, so too must the client, not a mountedTLSDir
return nil, fmt.Errorf("invalid TLS config, the 'solrClientTLS.pkcs12Secret' option is required when using a secret for server cert")
}
// shouldn't configure a client cert if it's the same as the server cert
if tls.ClientConfig.Options.PKCS12Secret == tls.ServerConfig.Options.PKCS12Secret {
return nil, fmt.Errorf("invalid TLS config, the 'solrClientTLS.pkcs12Secret' option should not be the same as the 'solrTLS.pkcs12Secret'")
}
_, err := tls.ClientConfig.VerifyKeystoreAndTruststoreSecretConfig(&r.Client)
if err != nil {
return nil, err
}
}
} else if serverCert.MountedTLSDir != nil {
// per-pod TLS files get mounted into a dir on the pod dynamically using some external agent / CSI driver type mechanism
// make sure the client cert, if configured, is also using the mounted dir option as mixing the two approaches is not supported
if tls.ClientConfig != nil && tls.ClientConfig.Options.MountedTLSDir == nil {
return nil, fmt.Errorf("invalid TLS config, client cert must also use 'mountedTLSDir' when using 'solrTLS.mountedTLSDir'")
}
} else {
return nil, fmt.Errorf("invalid TLS config, must supply either 'pkcs12Secret' or 'mountedTLSDir' for the server cert")
}
return tls, nil
}