|
5 | 5 | "fmt" |
6 | 6 | "strings" |
7 | 7 |
|
| 8 | + certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" |
8 | 9 | networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" |
9 | 10 | "github.com/openstack-k8s-operators/lib-common/modules/certmanager" |
10 | 11 | condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" |
@@ -195,15 +196,28 @@ func reconcileRabbitMQ( |
195 | 196 |
|
196 | 197 | hostname := fmt.Sprintf("%s.%s.svc", name, instance.Namespace) |
197 | 198 | tlsCert := "" |
| 199 | + commonName := fmt.Sprintf("%s.%s", hostname, ClusterInternalDomain) |
198 | 200 |
|
199 | 201 | if instance.Spec.TLS.PodLevel.Enabled { |
200 | 202 | certRequest := certmanager.CertificateRequest{ |
201 | 203 | IssuerName: instance.GetInternalIssuer(), |
202 | 204 | CertName: fmt.Sprintf("%s-svc", rabbitmq.Name), |
| 205 | + CommonName: &commonName, |
203 | 206 | Hostnames: []string{ |
204 | 207 | hostname, |
205 | 208 | fmt.Sprintf("%s.%s", hostname, ClusterInternalDomain), |
206 | 209 | }, |
| 210 | + Subject: &certmgrv1.X509Subject{ |
| 211 | + Organizations: []string{fmt.Sprintf("%s.%s", rabbitmq.Namespace, ClusterInternalDomain)}, |
| 212 | + }, |
| 213 | + Usages: []certmgrv1.KeyUsage{ |
| 214 | + "key encipherment", |
| 215 | + "data encipherment", |
| 216 | + "digital signature", |
| 217 | + "server auth", |
| 218 | + "client auth", |
| 219 | + "content commitment", |
| 220 | + }, |
207 | 221 | } |
208 | 222 | if instance.Spec.TLS.PodLevel.Internal.Cert.Duration != nil { |
209 | 223 | certRequest.Duration = &instance.Spec.TLS.PodLevel.Internal.Cert.Duration.Duration |
@@ -267,14 +281,63 @@ func reconcileRabbitMQ( |
267 | 281 | Log.Info("Setting AdditionalConfig") |
268 | 282 | // This is the same situation as RABBITMQ_UPGRADE_LOG above, |
269 | 283 | // except for the "main" rabbitmq log we can just force it to use the console. |
270 | | - rabbitmq.Spec.Rabbitmq.AdditionalConfig = "log.console = true" |
| 284 | + var settings []string |
| 285 | + settings = append(settings, "log.console = true") |
| 286 | + if tlsCert != "" { |
| 287 | + settings = append(settings, "ssl_options.verify = verify_none") |
| 288 | + } |
| 289 | + rabbitmq.Spec.Rabbitmq.AdditionalConfig = strings.Join(settings, "\n") |
271 | 290 | } |
272 | 291 |
|
273 | 292 | if tlsCert != "" { |
274 | 293 | rabbitmq.Spec.TLS.CaSecretName = tlsCert |
275 | 294 | rabbitmq.Spec.TLS.SecretName = tlsCert |
276 | 295 | // disable non tls listeners |
277 | 296 | rabbitmq.Spec.TLS.DisableNonTLSListeners = true |
| 297 | + // NOTE(dciabrin) RabbitMQ/Erlang needs a specific TLS configuration ordering |
| 298 | + // in ssl_options.versions for TLS to work with FIPS. We cannot enforce the right |
| 299 | + // ordering with AdditionalConfig, we have to pass a specific Erlang value via |
| 300 | + // the AdvancedConfig field. We also add configuration flags which were known to |
| 301 | + // work with FIPS in previous version of Openstack. |
| 302 | + rabbitmq.Spec.Rabbitmq.AdvancedConfig = `[ |
| 303 | + {rabbit, [ |
| 304 | + {ssl_options, [ |
| 305 | + {cacertfile,"/etc/rabbitmq-tls/ca.crt"}, |
| 306 | + {certfile,"/etc/rabbitmq-tls/tls.crt"}, |
| 307 | + {keyfile,"/etc/rabbitmq-tls/tls.key"}, |
| 308 | + {depth,1}, |
| 309 | + {secure_renegotiate,true}, |
| 310 | + {reuse_sessions,true}, |
| 311 | + {honor_cipher_order,false}, |
| 312 | + {honor_ecc_order,false}, |
| 313 | + {verify,verify_none}, |
| 314 | + {fail_if_no_peer_cert,false}, |
| 315 | + {versions, ['tlsv1.2','tlsv1.3']} |
| 316 | + ]} |
| 317 | + ]}, |
| 318 | + {rabbitmq_management, [ |
| 319 | + {ssl_config, [ |
| 320 | + {cacertfile,"/etc/rabbitmq-tls/ca.crt"}, |
| 321 | + {certfile,"/etc/rabbitmq-tls/tls.crt"}, |
| 322 | + {keyfile,"/etc/rabbitmq-tls/tls.key"}, |
| 323 | + {depth,1}, |
| 324 | + {secure_renegotiate,true}, |
| 325 | + {reuse_sessions,true}, |
| 326 | + {honor_cipher_order,false}, |
| 327 | + {honor_ecc_order,false}, |
| 328 | + {verify,verify_none}, |
| 329 | + {fail_if_no_peer_cert,false}, |
| 330 | + {versions, ['tlsv1.2','tlsv1.3']} |
| 331 | + ]} |
| 332 | + ]}, |
| 333 | + {client, [ |
| 334 | + {cacertfile, "/etc/rabbitmq-tls/ca.crt"}, |
| 335 | + {verify,verify_peer}, |
| 336 | + {secure_renegotiate,true}, |
| 337 | + {versions, ['tlsv1.2','tlsv1.3']} |
| 338 | + ]} |
| 339 | +]. |
| 340 | +` |
278 | 341 | } |
279 | 342 |
|
280 | 343 | // overrides |
|
0 commit comments