File 4721-Use-wsl-openssl.patch of Package erlang
From 9757ced839aa353969c923fc37c390ca9b7c9f13 Mon Sep 17 00:00:00 2001
From: Dan Gudmundsson <dgud@erlang.org>
Date: Fri, 7 Feb 2020 15:23:45 +0100
Subject: [PATCH 11/11] Use wsl openssl
Windows OpenSSL's openssl s_server code seems unstable and hangs
during some tests.
This commit tries to make the tests more stable.
---
 lib/ssl/test/ssl_test_lib.erl | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl
index b412379cfa..ef387c66cf 100644
--- a/lib/ssl/test/ssl_test_lib.erl
+++ b/lib/ssl/test/ssl_test_lib.erl
@@ -2411,6 +2411,31 @@ close_loop(Port, Time, SentClose) ->
 	    end
     end.
 
+portable_open_port("openssl" = Exe, Args0) ->
+    case os:getenv("WSLENV") of
+	false ->
+	    AbsPath = os:find_executable(Exe),
+	    ct:pal("open_port({spawn_executable, ~p}, [{args, ~p}, stderr_to_stdout]).",
+		   [AbsPath, Args0]),
+	    open_port({spawn_executable, AbsPath},
+		      [{args, Args0}, stderr_to_stdout]);
+	_ ->
+	    %% I can't get the new windows version of openssl.exe to be stable
+	    %% certain server tests are failing for no reason.
+	    %% This is using "linux" openssl via wslenv
+
+	    Translate = fun("c:/" ++ _ = Path) ->
+				string:trim(os:cmd("wsl wslpath -u " ++ Path));
+			   (Arg) ->
+				Arg
+			end,
+	    Args1 = [Translate(Arg) || Arg <- Args0],
+	    Args = ["/C","wsl","openssl"| Args1] ++ ["2>&1"],
+	    Cmd =  os:find_executable("cmd"),
+	    ct:pal("open_port({spawn_executable, ~p}, [{args, ~p}, stderr_to_stdout]).", [Cmd,Args]),
+	    open_port({spawn_executable, Cmd},
+		      [{args, Args}, stderr_to_stdout, hide])
+    end;
 portable_open_port(Exe, Args) ->
     AbsPath = os:find_executable(Exe),
     ct:pal("open_port({spawn_executable, ~p}, [{args, ~p}, stderr_to_stdout]).", [AbsPath, Args]),
@@ -2823,10 +2848,13 @@ digest() ->
 
 kill_openssl() ->
     case os:type() of
-        {unix, _} ->
-            os:cmd("pkill openssl");
         {win32, _} ->
-            os:cmd("cmd.exe /C \"taskkill /IM openssl.exe /F\"")
+            case os:getenv("WSLENV") of
+                false -> os:cmd("cmd.exe /C \"taskkill /IM openssl.exe /F\"");
+                _ -> os:cmd("wsl pkill openssl")
+            end;
+        _ ->
+            os:cmd("pkill openssl")
     end.
 
 hostname_format(Hostname) ->
-- 
2.16.4