Skip to content

Commit 65562c0

Browse files
committed
add db and reportdb as cnames
1 parent 7dcfedc commit 65562c0

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

mgradm/shared/podman/ssl.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ func prepareThirdPartyCertificates(
8686
if sslFlags.UseProvided() {
8787
log.Info().Msg(L("Using provided 3rd party server certificates"))
8888
if err := prepareThirdPartyCertificate(&sslFlags.Ca, &sslFlags.Server,
89-
shared_podman.CASecret, shared_podman.SSLCertSecret, shared_podman.SSLKeySecret, fqdn,
89+
shared_podman.CASecret, shared_podman.SSLCertSecret, shared_podman.SSLKeySecret,
90+
fqdn, "db", "reportdb",
9091
); err != nil {
9192
errs = append(errs, err)
9293
}
@@ -97,7 +98,8 @@ func prepareThirdPartyCertificates(
9798
log.Info().Msg(L("Using provided 3rd party database certificates"))
9899
if err := prepareThirdPartyCertificate(
99100
&sslFlags.DB.CA, &sslFlags.DB.SSLPair, shared_podman.DBCASecret,
100-
shared_podman.DBSSLCertSecret, shared_podman.DBSSLKeySecret, fqdn,
101+
shared_podman.DBSSLCertSecret, shared_podman.DBSSLKeySecret,
102+
fqdn, "db", "reportdb",
101103
); err != nil {
102104
errs = append(errs, err)
103105
}
@@ -191,11 +193,12 @@ func reuseExistingCertificates(image string, fqdn string, isDatabaseCheck bool)
191193
return
192194
}
193195

196+
fqdns := []string{fqdn, "db", "reportdb"}
197+
194198
// Upgrading from 5.1+ with all certificates as secrets
195199
if reuseExistingCertificatesFromSecrets(isDatabaseCheck) {
196200
secretName := shared_podman.SSLCertSecret
197201
caSecretName := shared_podman.CASecret
198-
fqdns := []string{fqdn}
199202
msg := L("Reusing the existing server certificate secrets")
200203
if isDatabaseCheck {
201204
secretName = shared_podman.DBSSLCertSecret
@@ -210,7 +213,7 @@ func reuseExistingCertificates(image string, fqdn string, isDatabaseCheck bool)
210213
}
211214

212215
// Upgrading from 5.0- with all certs in files
213-
return reuseExistingCertificatesFromMounts(image, tempDir, fqdn, isDatabaseCheck)
216+
return reuseExistingCertificatesFromMounts(image, tempDir, fqdns, isDatabaseCheck)
214217
}
215218

216219
func isFQDNMatchingCertificateSecret(secretName string, caSecretName string, fqdns ...string) bool {
@@ -279,7 +282,7 @@ func reuseExistingCertificatesFromSecrets(isDatabaseCheck bool) bool {
279282
func reuseExistingCertificatesFromMounts(
280283
image string,
281284
tempDir string,
282-
fqdn string,
285+
fqdns []string,
283286
isDatabaseCheck bool,
284287
) (bool, error) {
285288
caPath := path.Join(tempDir, "existing-ca.crt")
@@ -327,9 +330,11 @@ func reuseExistingCertificatesFromMounts(
327330
}
328331

329332
// We cannot reuse certificates not matching the requested FQDN
330-
if !isFQDNMatchingCertificate(fqdn, serverCert, caPath) {
331-
log.Warn().Msgf(L("Certificate file %[1]s doesn't match %[2]s FQDN."), crtCheckPath, fqdn)
332-
return false, nil
333+
for _, fqdn := range fqdns {
334+
if !isFQDNMatchingCertificate(fqdn, serverCert, caPath) {
335+
log.Warn().Msgf(L("Certificate file %[1]s doesn't match %[2]s."), crtCheckPath, fqdn)
336+
return false, nil
337+
}
333338
}
334339

335340
// Check for server certificate key
@@ -401,14 +406,15 @@ func generateServerCertificate(image string, sslFlags *adm_utils.InstallSSLFlags
401406
return err
402407
}
403408

409+
cnames := append([]string{fqdn, "db", "reportdb"}, sslFlags.Cnames...)
404410
env := map[string]string{
405411
"CERT_O": sslFlags.Org,
406412
"CERT_OU": sslFlags.OU,
407413
"CERT_CITY": sslFlags.City,
408414
"CERT_STATE": sslFlags.State,
409415
"CERT_COUNTRY": sslFlags.Country,
410416
"CERT_EMAIL": sslFlags.Email,
411-
"CERT_CNAMES": strings.Join(append([]string{fqdn}, sslFlags.Cnames...), " "),
417+
"CERT_CNAMES": strings.Join(cnames, " "),
412418
"CERT_PASS": sslFlags.Password,
413419
"HOSTNAME": fqdn,
414420
}

0 commit comments

Comments
 (0)