From b192874eb388b43e7e2fbff9ad3818442b9e202a Mon Sep 17 00:00:00 2001 From: Ilho Song Date: Wed, 13 May 2020 15:53:38 -0400 Subject: [PATCH 1/2] fix(generate_self_signed): replace use of quotes to double quotes for openssl many distribution of openssl for Windows cannot interprets single quotes as a shell evaluation, thus having single quotes when passing parameters to openssl command causes issues (filepaths includes quotes causes command to fail). Since double-qutoes are evaluated in both *nix shell as well as Windows shell, this commit updates use of single qutoes to double quotes to support both platforms better --- src/zotonic_ssl_certs.erl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/zotonic_ssl_certs.erl b/src/zotonic_ssl_certs.erl index 6c37fb2..66f9146 100644 --- a/src/zotonic_ssl_certs.erl +++ b/src/zotonic_ssl_certs.erl @@ -77,15 +77,15 @@ generate_self_signed(CertFile, PemFile, Options) -> Command = "openssl req -x509 -nodes" ++ " -days 3650" ++ " -sha256" - ++ " -subj '/CN=" ++ hostname(Options) + ++ " -subj \"/CN=" ++ hostname(Options) ++"/O=" ++ servername(Options) - ++"'" + ++"\"" ++ " -newkey rsa:"++?BITS++" " - ++ " -keyout " ++ z_filelib:os_filename(KeyFile) - ++ " -out " ++ z_filelib:os_filename(CertFile), - % error_logger:info_msg("SSL: ~p", [Command]), + ++ " -keyout \"" ++ string:strip(z_filelib:os_filename(KeyFile), both, $') ++ "\"" + ++ " -out \"" ++ string:strip(z_filelib:os_filename(CertFile), both, $') ++ "\"", + error_logger:info_msg("SSL: ~p", [Command]), Result = os:cmd(Command), - % error_logger:info_msg("SSL: ~p", [Result]), + error_logger:info_msg("SSL: ~p", [Result]), case file:read_file(KeyFile) of {ok, <<"-----BEGIN PRIVATE KEY", _/binary>>} -> os:cmd("openssl rsa -in "++KeyFile++" -out "++PemFile), From ad1487f4909cf854e16cb5bc7c31f6ed127306a3 Mon Sep 17 00:00:00 2001 From: Ilho Song Date: Wed, 13 May 2020 16:18:46 -0400 Subject: [PATCH 2/2] chore: restore orignally commented code --- src/zotonic_ssl_certs.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zotonic_ssl_certs.erl b/src/zotonic_ssl_certs.erl index 66f9146..dadd6ae 100644 --- a/src/zotonic_ssl_certs.erl +++ b/src/zotonic_ssl_certs.erl @@ -83,9 +83,9 @@ generate_self_signed(CertFile, PemFile, Options) -> ++ " -newkey rsa:"++?BITS++" " ++ " -keyout \"" ++ string:strip(z_filelib:os_filename(KeyFile), both, $') ++ "\"" ++ " -out \"" ++ string:strip(z_filelib:os_filename(CertFile), both, $') ++ "\"", - error_logger:info_msg("SSL: ~p", [Command]), + % error_logger:info_msg("SSL: ~p", [Command]), Result = os:cmd(Command), - error_logger:info_msg("SSL: ~p", [Result]), + % error_logger:info_msg("SSL: ~p", [Result]), case file:read_file(KeyFile) of {ok, <<"-----BEGIN PRIVATE KEY", _/binary>>} -> os:cmd("openssl rsa -in "++KeyFile++" -out "++PemFile),