Skip to content

Commit

Permalink
Set default CA secret name even if the SSL is disabled. (#624)
Browse files Browse the repository at this point in the history
Signed-off-by: kamolhasan <kamol@appscode.com>
  • Loading branch information
Md Kamol Hasan committed Oct 21, 2020
1 parent c3710b6 commit 5f17e1b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions apis/kubedb/v1alpha2/elasticsearch_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,20 @@ func (e *Elasticsearch) SetTLSDefaults(esVersion *v1alpha1.ElasticsearchVersion)
tlsConfig = &kmapi.TLSConfig{}
}

// If the issuerRef is nil, the operator will create the CA certificate.
// It is required even if the spec.EnableSSL is false. Because, the transport
// layer is always secured with certificates. Unless you turned off all the security
// by setting spec.DisableSecurity to true.
if tlsConfig.IssuerRef == nil {
tlsConfig.Certificates = kmapi.SetMissingSpecForCertificate(tlsConfig.Certificates, kmapi.CertificateSpec{
Alias: string(ElasticsearchCACert),
SecretName: e.CertificateName(ElasticsearchCACert),
Subject: &kmapi.X509Subject{
Organizations: []string{KubeDBOrganization},
},
})
}

// transport layer is always secured with certificate
tlsConfig.Certificates = kmapi.SetMissingSpecForCertificate(tlsConfig.Certificates, kmapi.CertificateSpec{
Alias: string(ElasticsearchTransportCert),
Expand All @@ -339,18 +353,6 @@ func (e *Elasticsearch) SetTLSDefaults(esVersion *v1alpha1.ElasticsearchVersion)

// If SSL is enabled, set missing certificate spec
if e.Spec.EnableSSL {

// If the issuerRef is nil, the operator will create the CA certificate.
if tlsConfig.IssuerRef == nil {
tlsConfig.Certificates = kmapi.SetMissingSpecForCertificate(tlsConfig.Certificates, kmapi.CertificateSpec{
Alias: string(ElasticsearchCACert),
SecretName: e.CertificateName(ElasticsearchCACert),
Subject: &kmapi.X509Subject{
Organizations: []string{KubeDBOrganization},
},
})
}

// http
tlsConfig.Certificates = kmapi.SetMissingSpecForCertificate(tlsConfig.Certificates, kmapi.CertificateSpec{
Alias: string(ElasticsearchHTTPCert),
Expand Down

0 comments on commit 5f17e1b

Please sign in to comment.