summaryrefslogtreecommitdiff
path: root/lib/ssl/src/ssl_config.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <ingela@erlang.org>2022-01-05 20:03:56 +0100
committerIngela Anderton Andin <ingela@erlang.org>2022-02-28 09:50:49 +0100
commitbf7081f32a19ee457f0c0c685b89ab1215a3ec53 (patch)
tree98e519da7d69dc0f8b1bfbddaa599a6f2a906c36 /lib/ssl/src/ssl_config.erl
parent950f81c0187cab943874037ab87dfd22ee0cd6d9 (diff)
downloaderlang-bf7081f32a19ee457f0c0c685b89ab1215a3ec53.tar.gz
ssl: Prepare code to have several certificate key pairs to choose from
Diffstat (limited to 'lib/ssl/src/ssl_config.erl')
-rw-r--r--lib/ssl/src/ssl_config.erl14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/ssl/src/ssl_config.erl b/lib/ssl/src/ssl_config.erl
index 80a5b4f44c..65d4259ab4 100644
--- a/lib/ssl/src/ssl_config.erl
+++ b/lib/ssl/src/ssl_config.erl
@@ -49,12 +49,12 @@ init(#{erl_dist := ErlDist,
init_manager_name(ErlDist),
- {ok, #{pem_cache := PemCache} = Config}
+ {ok, #{pem_cache := PemCache} = Config, Certs}
= init_certificates(SslOpts, Role),
PrivateKey =
init_private_key(PemCache, Key, KeyFile, Password, Role),
DHParams = init_diffie_hellman(PemCache, DH, DHFile, Role),
- {ok, Config#{private_key => PrivateKey, dh_params => DHParams}}.
+ {ok, Config#{cert_key_pairs => [#{private_key => PrivateKey, certs => Certs}], dh_params => DHParams}}.
pre_1_3_session_opts(Role) ->
{Cb, InitArgs} = session_cb_opts(Role),
@@ -141,28 +141,28 @@ init_certificates(#{cacerts := CaCerts,
init_certificates(OwnCerts, Config, CertFile, Role).
init_certificates(undefined, Config, <<>>, _) ->
- {ok, Config#{own_certificates => undefined}};
+ {ok, Config, undefined};
init_certificates(undefined, #{pem_cache := PemCache} = Config, CertFile, client) ->
try
%% OwnCert | [OwnCert | Chain]
OwnCerts = ssl_certificate:file_to_certificats(CertFile, PemCache),
- {ok, Config#{own_certificates => OwnCerts}}
+ {ok, Config, OwnCerts}
catch _Error:_Reason ->
- {ok, Config#{own_certificates => undefined}}
+ {ok, Config, undefined}
end;
init_certificates(undefined, #{pem_cache := PemCache} = Config, CertFile, server) ->
try
%% OwnCert | [OwnCert | Chain]
OwnCerts = ssl_certificate:file_to_certificats(CertFile, PemCache),
- {ok, Config#{own_certificates => OwnCerts}}
+ {ok, Config, OwnCerts}
catch
_:Reason ->
file_error(CertFile, {certfile, Reason})
end;
init_certificates(OwnCerts, Config, _, _) ->
- {ok, Config#{own_certificates => OwnCerts}}.
+ {ok, Config, OwnCerts}.
init_private_key(_, #{algorithm := Alg} = Key, _, _Password, _Client) when Alg == ecdsa;
Alg == rsa;
Alg == dss ->