File 3087-ftp-Fix-generated-certificates-to-work-with-new-open.patch of Package erlang
From 48019cc46849e656165d88f8a1dd2ecc769d5ec5 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 5 Jan 2022 16:54:16 +0100
Subject: [PATCH 07/11] ftp: Fix generated certificates to work with new
openssl
---
lib/ftp/test/ftp_test_lib.erl | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/lib/ftp/test/ftp_test_lib.erl b/lib/ftp/test/ftp_test_lib.erl
index f5fbc39037..2330d4f2c7 100644
--- a/lib/ftp/test/ftp_test_lib.erl
+++ b/lib/ftp/test/ftp_test_lib.erl
@@ -28,14 +28,15 @@
make_cert_files(Dir) ->
#{server_config := ServerConf,
client_config := _} =
- public_key:pkix_test_data(#{server_chain =>
- #{root => [{key, hardcode_rsa_key(1)}],
- intermediates => [[{key, hardcode_rsa_key(2)}]],
- peer => [{key, hardcode_rsa_key(3)}]},
- client_chain =>
- #{root => [{key, hardcode_rsa_key(1)}],
- intermediates => [[{key, hardcode_rsa_key(3)}]],
- peer => [{key, hardcode_rsa_key(2)}]}}),
+ public_key:pkix_test_data(
+ #{server_chain =>
+ #{root => [{key, hardcode_rsa_key(1)},{digest,appropriate_sha()}],
+ intermediates => [[{key, hardcode_rsa_key(2)},{digest,appropriate_sha()}]],
+ peer => [{key, hardcode_rsa_key(3)},{digest,appropriate_sha()}]},
+ client_chain =>
+ #{root => [{key, hardcode_rsa_key(1)},{digest,appropriate_sha()}],
+ intermediates => [[{key, hardcode_rsa_key(3)},{digest,appropriate_sha()}]],
+ peer => [{key, hardcode_rsa_key(2)},{digest,appropriate_sha()}]}}),
CaCertFile = filename:join(Dir, "server-cacerts.pem"),
CertFile = filename:join(Dir, "server-cert.pem"),
@@ -48,6 +49,20 @@ make_cert_files(Dir) ->
der_to_pem(KeyFile, [key_entry(Key)]),
der_to_pem(CaCertFile, ca_entries(CAs)).
+appropriate_sha() ->
+ Hashes = proplists:get_value(hashs, crypto:supports()),
+ case os:cmd("openssl version") of
+ "OpenSSL 0.9.8" ++ _ ->
+ sha;
+ _ ->
+ case lists:member(sha256, Hashes) of
+ true ->
+ sha256;
+ false ->
+ sha
+ end
+ end.
+
cert_entry(Cert) ->
{'Certificate', Cert, not_encrypted}.
--
2.31.1