@@ -97,7 +97,8 @@ func prepareThirdPartyCertificates(
9797 log .Info ().Msg (L ("Using provided 3rd party database certificates" ))
9898 if err := prepareThirdPartyCertificate (
9999 & sslFlags .DB .CA , & sslFlags .DB .SSLPair , shared_podman .DBCASecret ,
100- shared_podman .DBSSLCertSecret , shared_podman .DBSSLKeySecret , fqdn ,
100+ shared_podman .DBSSLCertSecret , shared_podman .DBSSLKeySecret ,
101+ fqdn , "db" , "reportdb" ,
101102 ); err != nil {
102103 errs = append (errs , err )
103104 }
@@ -123,7 +124,7 @@ func PrepareSSLCertificates(image string, sslFlags *adm_utils.InstallSSLFlags, t
123124 // Do we have secrets or certificates from volumes to reuse?
124125 if ! serverCertReady {
125126 // Check if this is an upgrade scenario and there is existing CA and cert/key pair
126- serverCertReady , err = reuseExistingCertificates (image , fqdn , false )
127+ serverCertReady , err = reuseExistingCertificates (image , [] string { fqdn } , false )
127128 }
128129 if serverCertReady && err != nil {
129130 // we found certificates, but there was trouble loading it
@@ -132,7 +133,9 @@ func PrepareSSLCertificates(image string, sslFlags *adm_utils.InstallSSLFlags, t
132133
133134 if ! dbCertReady {
134135 // Check if this is an upgrade scenario and there is existing CA and cert/key pair
135- dbCertReady , err = reuseExistingCertificates (image , fqdn , true )
136+
137+ fqdns := []string {fqdn , "db" , "reportdb" }
138+ dbCertReady , err = reuseExistingCertificates (image , fqdns , true )
136139 }
137140 if dbCertReady && err != nil {
138141 // we found certificates, but there was trouble loading it
@@ -183,7 +186,7 @@ func validateCA(image string, sslFlags *adm_utils.InstallSSLFlags, tz string) er
183186 return nil
184187}
185188
186- func reuseExistingCertificates (image string , fqdn string , isDatabaseCheck bool ) (reused bool , err error ) {
189+ func reuseExistingCertificates (image string , fqdns [] string , isDatabaseCheck bool ) (reused bool , err error ) {
187190 // Write the ordered cert and Root CA to temp files
188191 tempDir , cleaner , err := utils .TempDir ()
189192 defer cleaner ()
@@ -195,7 +198,6 @@ func reuseExistingCertificates(image string, fqdn string, isDatabaseCheck bool)
195198 if reuseExistingCertificatesFromSecrets (isDatabaseCheck ) {
196199 secretName := shared_podman .SSLCertSecret
197200 caSecretName := shared_podman .CASecret
198- fqdns := []string {fqdn }
199201 msg := L ("Reusing the existing server certificate secrets" )
200202 if isDatabaseCheck {
201203 secretName = shared_podman .DBSSLCertSecret
@@ -210,7 +212,7 @@ func reuseExistingCertificates(image string, fqdn string, isDatabaseCheck bool)
210212 }
211213
212214 // Upgrading from 5.0- with all certs in files
213- return reuseExistingCertificatesFromMounts (image , tempDir , fqdn , isDatabaseCheck )
215+ return reuseExistingCertificatesFromMounts (image , tempDir , fqdns , isDatabaseCheck )
214216}
215217
216218func isFQDNMatchingCertificateSecret (secretName string , caSecretName string , fqdns ... string ) bool {
@@ -279,7 +281,7 @@ func reuseExistingCertificatesFromSecrets(isDatabaseCheck bool) bool {
279281func reuseExistingCertificatesFromMounts (
280282 image string ,
281283 tempDir string ,
282- fqdn string ,
284+ fqdns [] string ,
283285 isDatabaseCheck bool ,
284286) (bool , error ) {
285287 caPath := path .Join (tempDir , "existing-ca.crt" )
@@ -327,9 +329,11 @@ func reuseExistingCertificatesFromMounts(
327329 }
328330
329331 // 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
332+ for _ , fqdn := range fqdns {
333+ if ! isFQDNMatchingCertificate (fqdn , serverCert , caPath ) {
334+ log .Warn ().Msgf (L ("Certificate file %[1]s doesn't match %[2]s." ), crtCheckPath , fqdn )
335+ return false , nil
336+ }
333337 }
334338
335339 // Check for server certificate key
@@ -401,14 +405,15 @@ func generateServerCertificate(image string, sslFlags *adm_utils.InstallSSLFlags
401405 return err
402406 }
403407
408+ cnames := append ([]string {fqdn , "db" , "reportdb" }, sslFlags .Cnames ... )
404409 env := map [string ]string {
405410 "CERT_O" : sslFlags .Org ,
406411 "CERT_OU" : sslFlags .OU ,
407412 "CERT_CITY" : sslFlags .City ,
408413 "CERT_STATE" : sslFlags .State ,
409414 "CERT_COUNTRY" : sslFlags .Country ,
410415 "CERT_EMAIL" : sslFlags .Email ,
411- "CERT_CNAMES" : strings .Join (append ([] string { fqdn }, sslFlags . Cnames ... ) , " " ),
416+ "CERT_CNAMES" : strings .Join (cnames , " " ),
412417 "CERT_PASS" : sslFlags .Password ,
413418 "HOSTNAME" : fqdn ,
414419 }
0 commit comments