summaryrefslogtreecommitdiff
path: root/tests/x509self.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/x509self.c')
-rw-r--r--tests/x509self.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/tests/x509self.c b/tests/x509self.c
index 3bc4d094b8..e0e620f89e 100644
--- a/tests/x509self.c
+++ b/tests/x509self.c
@@ -156,22 +156,22 @@ client (void)
gnutls_perror (ret);
goto end;
}
- else
+ else if (debug)
{
success ("client: Handshake was completed\n");
}
- success ("client: TLS version is: %s\n",
+ if (debug) success ("client: TLS version is: %s\n",
gnutls_protocol_get_name (gnutls_protocol_get_version (session)));
/* see the Getting peer's information example */
- print_info (session);
+ if (debug) print_info (session);
ret = gnutls_record_send (session, MSG, strlen (MSG));
if (ret == strlen (MSG))
{
- success ("client: sent record.\n");
+ if (debug) success ("client: sent record.\n");
}
else
{
@@ -182,15 +182,15 @@ client (void)
ret = gnutls_record_recv (session, buffer, MAX_BUF);
- success ("client: recv returned %d.\n", ret);
+ if (debug) success ("client: recv returned %d.\n", ret);
if (ret == GNUTLS_E_REHANDSHAKE)
{
- success ("client: doing handshake!\n");
+ if (debug) success ("client: doing handshake!\n");
ret = gnutls_handshake (session);
if (ret == 0)
{
- success ("client: handshake complete, reading again.\n");
+ if (debug) success ("client: handshake complete, reading again.\n");
ret = gnutls_record_recv (session, buffer, MAX_BUF);
}
else
@@ -201,7 +201,7 @@ client (void)
if (ret == 0)
{
- success ("client: Peer has closed the TLS connection\n");
+ if (debug) success ("client: Peer has closed the TLS connection\n");
goto end;
}
else if (ret < 0)
@@ -210,12 +210,15 @@ client (void)
goto end;
}
- printf ("- Received %d bytes: ", ret);
- for (ii = 0; ii < ret; ii++)
+ if (debug)
{
- fputc (buffer[ii], stdout);
+ printf ("- Received %d bytes: ", ret);
+ for (ii = 0; ii < ret; ii++)
+ {
+ fputc (buffer[ii], stdout);
+ }
+ fputs ("\n", stdout);
}
- fputs ("\n", stdout);
gnutls_bye (session, GNUTLS_SHUT_RDWR);
@@ -369,7 +372,7 @@ server_start (void)
return;
}
- success ("server: ready. Listening to port '%d'.\n", PORT);
+ if (debug) success ("server: ready. Listening to port '%d'.\n", PORT);
}
static void
@@ -389,7 +392,7 @@ server (void)
gnutls_certificate_set_x509_key_mem (x509_cred, &server_cert, &server_key,
GNUTLS_X509_FMT_PEM);
- success ("Launched, generating DH parameters...\n");
+ if (debug) success ("Launched, generating DH parameters...\n");
generate_dh_params ();
@@ -401,7 +404,7 @@ server (void)
sd = accept (listen_sd, (SA *) & sa_cli, &client_len);
- success ("server: connection from %s, port %d\n",
+ if (debug) success ("server: connection from %s, port %d\n",
inet_ntop (AF_INET, &sa_cli.sin_addr, topbuf,
sizeof (topbuf)), ntohs (sa_cli.sin_port));
@@ -414,13 +417,15 @@ server (void)
fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
return;
}
- success ("server: Handshake was completed\n");
-
- success ("server: TLS version is: %s\n",
+ if (debug)
+ {
+ success ("server: Handshake was completed\n");
+ success ("server: TLS version is: %s\n",
gnutls_protocol_get_name (gnutls_protocol_get_version (session)));
+ }
/* see the Getting peer's information example */
- print_info (session);
+ if (debug) print_info (session);
i = 0;
for (;;)
@@ -430,7 +435,7 @@ server (void)
if (ret == 0)
{
- success ("server: Peer has closed the GNUTLS connection\n");
+ if (debug) success ("server: Peer has closed the GNUTLS connection\n");
break;
}
else if (ret < 0)
@@ -443,7 +448,7 @@ server (void)
gnutls_certificate_server_set_request (session,
GNUTLS_CERT_REQUEST);
- success ("server: got data, forcing rehandshake.\n");
+ if (debug) success ("server: got data, forcing rehandshake.\n");
ret = gnutls_rehandshake (session);
if (ret < 0)
@@ -461,7 +466,7 @@ server (void)
break;
}
- success ("server: rehandshake complete.\n");
+ if (debug) success ("server: rehandshake complete.\n");
/* echo data back to the client
*/
@@ -483,7 +488,7 @@ server (void)
gnutls_global_deinit ();
- success ("server: finished\n");
+ if (debug) success ("server: finished\n");
}