Skip to content

Commit

Permalink
Allow the client to close the connection first
Browse files Browse the repository at this point in the history
This is necessary when testing against OpenSSL 1.0.2g.

In the server, flush more often. Otherwise, when stdout is redirected to a
file, the server gets killed before it writes important information, such as
the logs that we expect in the test cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
  • Loading branch information
gilles-peskine-arm committed Sep 4, 2024
1 parent 43ab475 commit d224f45
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion programs/ssl/ssl_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,19 @@ int main(void)
mbedtls_printf(" %d bytes written\n\n%s\n", len, (char *) buf);

mbedtls_printf(" . Closing the connection...");
fflush(stdout);

while ((ret = mbedtls_ssl_close_notify(&ssl)) < 0) {
if (ret != MBEDTLS_ERR_SSL_WANT_READ &&
ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
ret != MBEDTLS_ERR_SSL_WANT_WRITE &&
ret != MBEDTLS_ERR_NET_CONN_RESET) {
mbedtls_printf(" failed\n ! mbedtls_ssl_close_notify returned %d\n\n", ret);
goto reset;
}
}

mbedtls_printf(" ok\n");
fflush(stdout);

ret = 0;
goto reset;
Expand Down

0 comments on commit d224f45

Please sign in to comment.