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

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