summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexej Tessaro <[email protected]>2015-10-20 15:54:28 +0100
committerLoïc Hoguin <[email protected]>2021-03-18 10:24:32 +0100
commit478aa272708ed4ad282ca02bed41a5320330e8af (patch)
treed5de4854d5c7acfe9b64f88f341072d97dab13f2
parentc482e1c602a964d54d2398f43a0e14b1cd63cce3 (diff)
downloadct_helper-478aa272708ed4ad282ca02bed41a5320330e8af.tar.gz
ct_helper-478aa272708ed4ad282ca02bed41a5320330e8af.tar.bz2
ct_helper-478aa272708ed4ad282ca02bed41a5320330e8af.zip
Add make_certs in specific directoryHEADmaster
-rw-r--r--src/ct_helper.erl17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ct_helper.erl b/src/ct_helper.erl
index ff6c3d7..e3c6bec 100644
--- a/src/ct_helper.erl
+++ b/src/ct_helper.erl
@@ -29,6 +29,7 @@
-export([is_process_down/2]).
-export([make_certs/0]).
-export([make_certs_in_ets/0]).
+-export([make_certs_in_dir/1]).
-export([name/0]).
-export([start/1]).
@@ -200,6 +201,22 @@ make_certs() ->
{Cert, {Asn1Type, Der, _}} = erl_make_certs:make_cert([{issuer, CaInfo}]),
{CaCert, Cert, {Asn1Type, Der}}.
+%% @doc Create a set of certificates and store them in a directory.
+
+make_certs_in_dir(Dir) ->
+ {CaCert, Cert, Key} = make_certs(),
+ CertFile = filename:join(Dir, "cert.pem"),
+ CaCertsFile = filename:join(Dir, "cacerts.pem"),
+ KeyFile = filename:join(Dir, "key.pem"),
+ CertPem = public_key:pem_encode([{'Certificate', Cert, not_encrypted}]),
+ CaCertsPem = public_key:pem_encode([{'Certificate', CaCert, not_encrypted}]),
+ {KeyAsn1Type, KeyDer} = Key,
+ KeyPem = public_key:pem_encode([{KeyAsn1Type, KeyDer, not_encrypted}]),
+ ok = file:write_file(CertFile, CertPem),
+ ok = file:write_file(CaCertsFile, CaCertsPem),
+ ok = file:write_file(KeyFile, KeyPem),
+ {CaCertsFile, CertFile, KeyFile}.
+
%% @doc Create a set of certificates and store them in an ets table.
%%
%% The verify options are there so that: