Skip to content

Commit 7b45fe3

Browse files
committed
Generate RabbitMQ TLS config that works with FIPS
When TLS is enabled in RabbitMQ with FIPS engaged, the RabbitMQ server has to be given specific TLS options in the RabbitMQ configuration otherwise the rabbitmq Erlang application will fail to create TLS sockets with: {insufficient_crypto_support {'tlsv1.3',{versions,['tlsv1.3','tlsv1.2']}}}}}}}}} We now reuse the same config as we had in previous versions of Openstack as they were known to work with FIPS. Moreover the configuration has to be passed as an Erlang structure to ensure the right orderning of option ssl_options.versions. In addition, it seems RabbitMQ won't start correctly unless the certificate has additional key usage capabilities configured, and the CA created for the control plane uses RSA instead of ECDSA. Related: OSPRH-6889
1 parent 706510e commit 7b45fe3

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

‎pkg/openstack/ca.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ func createRootCACertAndIssuer(
530530
CommonName: caName,
531531
SecretName: caName,
532532
PrivateKey: &certmgrv1.CertificatePrivateKey{
533-
Algorithm: "ECDSA",
534-
Size: 256,
533+
Algorithm: "RSA",
534+
Size: 3072,
535535
},
536536
IssuerRef: certmgrmetav1.ObjectReference{
537537
Name: selfsignedIssuerReq.Name,

‎pkg/openstack/rabbitmq.go‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"strings"
77

8+
certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
89
networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
910
"github.com/openstack-k8s-operators/lib-common/modules/certmanager"
1011
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
@@ -195,15 +196,28 @@ func reconcileRabbitMQ(
195196

196197
hostname := fmt.Sprintf("%s.%s.svc", name, instance.Namespace)
197198
tlsCert := ""
199+
commonName := fmt.Sprintf("%s.%s", hostname, ClusterInternalDomain)
198200

199201
if instance.Spec.TLS.PodLevel.Enabled {
200202
certRequest := certmanager.CertificateRequest{
201203
IssuerName: instance.GetInternalIssuer(),
202204
CertName: fmt.Sprintf("%s-svc", rabbitmq.Name),
205+
CommonName: &commonName,
203206
Hostnames: []string{
204207
hostname,
205208
fmt.Sprintf("%s.%s", hostname, ClusterInternalDomain),
206209
},
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+
},
207221
}
208222
if instance.Spec.TLS.PodLevel.Internal.Cert.Duration != nil {
209223
certRequest.Duration = &instance.Spec.TLS.PodLevel.Internal.Cert.Duration.Duration
@@ -267,14 +281,63 @@ func reconcileRabbitMQ(
267281
Log.Info("Setting AdditionalConfig")
268282
// This is the same situation as RABBITMQ_UPGRADE_LOG above,
269283
// 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")
271290
}
272291

273292
if tlsCert != "" {
274293
rabbitmq.Spec.TLS.CaSecretName = tlsCert
275294
rabbitmq.Spec.TLS.SecretName = tlsCert
276295
// disable non tls listeners
277296
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+
`
278341
}
279342

280343
// overrides

0 commit comments

Comments
 (0)