File 4701-ssl-fix-OCSP-tests.patch of Package erlang

From 45b766fb735bf7dbda9626b4bf12ed7580890f8b Mon Sep 17 00:00:00 2001
From: Jakub Witczak <kuba@erlang.org>
Date: Wed, 16 Mar 2022 16:38:26 +0100
Subject: [PATCH 1/2] ssl: fix OCSP tests

- postponde data reception in wait_ocsp_stapling state
- increase time trap for DTLS test group
---
 lib/ssl/src/tls_dtls_connection.erl | 20 ++++++++++----------
 lib/ssl/test/openssl_ocsp_SUITE.erl | 12 +++++++++++-
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/lib/ssl/src/tls_dtls_connection.erl b/lib/ssl/src/tls_dtls_connection.erl
index cfc2a547e5..9f0bf8132e 100644
--- a/lib/ssl/src/tls_dtls_connection.erl
+++ b/lib/ssl/src/tls_dtls_connection.erl
@@ -265,20 +265,20 @@ abbreviated(Type, Event, State) ->
 	                     #state{}) ->
 		gen_statem:state_function_result().
 %%--------------------------------------------------------------------
-wait_ocsp_stapling(internal, #certificate{}, #state{static_env = #static_env{protocol_cb = Connection}} = State) ->
+wait_ocsp_stapling(internal, #certificate{},
+                   #state{static_env = #static_env{protocol_cb = _Connection}} = State) ->
     %% Postpone message, should be handled in certify after receiving staple message
-    Connection:next_event(?FUNCTION_NAME, no_record, State, [{postpone, true}]);
+    {next_state, ?FUNCTION_NAME, State, [{postpone, true}]};
 %% Receive OCSP staple message
 wait_ocsp_stapling(internal, #certificate_status{} = CertStatus,
-                   #state{static_env = #static_env{protocol_cb = Connection},
+                   #state{static_env = #static_env{protocol_cb = _Connection},
                           handshake_env = #handshake_env{
                                              ocsp_stapling_state = OcspState} = HsEnv} = State) ->
-    Connection:next_event(certify, no_record, 
-                          State#state{handshake_env = HsEnv#handshake_env{ocsp_stapling_state = 
+    {next_state, certify, State#state{handshake_env = HsEnv#handshake_env{ocsp_stapling_state =
                                                                               OcspState#{ocsp_expect => stapled,
-                                                                                         ocsp_response => CertStatus}}});
+                                                                                         ocsp_response => CertStatus}}}};
 %% Server did not send OCSP staple message
-wait_ocsp_stapling(internal, Msg, #state{static_env = #static_env{protocol_cb = Connection},
+wait_ocsp_stapling(internal, Msg, #state{static_env = #static_env{protocol_cb = _Connection},
                                          handshake_env = #handshake_env{
                                                             ocsp_stapling_state = OcspState} = HsEnv} = State)
   when is_record(Msg, server_key_exchange) orelse
@@ -286,10 +286,10 @@ wait_ocsp_stapling(internal, Msg, #state{static_env = #static_env{protocol_cb =
        is_record(Msg, certificate_request) orelse
        is_record(Msg, server_hello_done) orelse
        is_record(Msg, client_key_exchange) ->
-    Connection:next_event(certify, no_record, 
-                          State#state{handshake_env = 
+    {next_state, certify, State#state{handshake_env =
                                           HsEnv#handshake_env{ocsp_stapling_state = OcspState#{ocsp_expect => undetermined}}},
-                          [{postpone, true}]);
+     [{postpone, true}]};
+
 wait_ocsp_stapling(internal, #hello_request{}, _) ->
     keep_state_and_data;
 wait_ocsp_stapling(Type, Event, State) ->
diff --git a/lib/ssl/test/openssl_ocsp_SUITE.erl b/lib/ssl/test/openssl_ocsp_SUITE.erl
index c66cb4b810..a205bb3714 100644
--- a/lib/ssl/test/openssl_ocsp_SUITE.erl
+++ b/lib/ssl/test/openssl_ocsp_SUITE.erl
@@ -107,6 +107,7 @@ end_per_suite(Config) ->
     ResponderPid = proplists:get_value(responder_pid, Config),
     ssl_test_lib:close(ResponderPid),
     ok = ssl:stop(),
+    ssl_test_lib:kill_openssl(), % terminate OpenSSL OCSP responder process
     application:stop(crypto).
 
 %%--------------------------------------------------------------------
@@ -118,8 +119,14 @@ end_per_group(GroupName, Config) ->
 
 %%--------------------------------------------------------------------
 init_per_testcase(_TestCase, Config) ->
+    Timetrap = case group_name(Config) of
+                   'dtlsv1.2' ->
+                       {seconds, 300}; % DTLS require more time for handling retransmissions
+                   _ ->
+                       {seconds, 10}
+               end,
+    ct:timetrap(Timetrap),
     ssl_test_lib:ct_log_supported_protocol_versions(Config),
-    ct:timetrap({seconds, 10}),
     Config.
 
 end_per_testcase(_TestCase, Config) ->
@@ -382,3 +389,6 @@ get_free_port() ->
     ok = gen_tcp:close(Listen),
     Port.
 
+group_name(Config) ->
+    GroupProp = proplists:get_value(tc_group_properties, Config),
+    proplists:get_value(name, GroupProp).
-- 
2.34.1

openSUSE Build Service is sponsored by