Blame SOURCES/0003-Custodia-use-a-stronger-encryption-algo-when-exporting-keys_rhbz#2032806.patch

b7b64b
From 653a7fe02880c168755984133ee143567cc7bb4e Mon Sep 17 00:00:00 2001
b7b64b
From: Francisco Trivino <ftrivino@redhat.com>
b7b64b
Date: Wed, 26 Jan 2022 15:43:39 +0100
b7b64b
Subject: [PATCH] Custodia: use a stronger encryption algo when exporting keys
b7b64b
b7b64b
The Custodia key export handler is using the default's OpenSSL encryption
b7b64b
scheme for PKCS#12.
b7b64b
b7b64b
This represents an issue when performing a migration from CentOS Stream 8 (C8S)
b7b64b
to CentOS Steam 9 (C9S) where the Custodia client running in the new C9S
b7b64b
replica talks to the Custodia server on C8S source server. The later creates an
b7b64b
encrypted PKCS#12 file that contains the cert and the key using the OpenSSL's
b7b64b
default encryption scheme, which is no longer supported on C9S.
b7b64b
b7b64b
This commit enforces a stronger encryption algorigthm by adding following
b7b64b
arguments to the Custodia server handler:
b7b64b
b7b64b
-keypbe AES-256-CBC -certpbe AES-256-CBC -macalg sha384
b7b64b
b7b64b
The new arguments enforce stronger PBEv2 instead of the insecure PBEv1.
b7b64b
b7b64b
Fixes: https://pagure.io/freeipa/issue/9101
b7b64b
b7b64b
Signed-off-by: Francisco Trivino <ftrivino@redhat.com>
b7b64b
Reviewed-By: Christian Heimes <cheimes@redhat.com>
b7b64b
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
b7b64b
---
b7b64b
 ipaserver/secrets/handlers/pemfile.py | 3 +++
b7b64b
 1 file changed, 3 insertions(+)
b7b64b
b7b64b
diff --git a/ipaserver/secrets/handlers/pemfile.py b/ipaserver/secrets/handlers/pemfile.py
b7b64b
index 4e8eff0e3..ad36bd020 100644
b7b64b
--- a/ipaserver/secrets/handlers/pemfile.py
b7b64b
+++ b/ipaserver/secrets/handlers/pemfile.py
b7b64b
@@ -31,6 +31,9 @@ def export_key(args, tmpdir):
b7b64b
         '-out', pk12file,
b7b64b
         '-inkey', args.keyfile,
b7b64b
         '-password', 'file:{pk12pwfile}'.format(pk12pwfile=pk12pwfile),
b7b64b
+        '-keypbe', 'AES-256-CBC',
b7b64b
+        '-certpbe', 'AES-256-CBC',
b7b64b
+        '-macalg', 'sha384',
b7b64b
     ])
b7b64b
 
b7b64b
     with open(pk12file, 'rb') as f:
b7b64b
-- 
b7b64b
2.34.1
b7b64b