printf("- Peer has closed the TLS connection\n");
goto end;
} else if (ret < 0) {
- fprintf(stderr, "*** Received corrupted data(%d) - server has terminated the connection abnormally\n",
- ret);
+ fprintf(stderr, "*** Error: %s\n", gnutls_strerror(ret));
goto end;
} else if (ret > 0) {
printf("- Received %d bytes: ", ret);
printf("- Peer has closed the GNUTLS connection\n");
goto end;
} else {
- fprintf(stderr, "*** Received corrupted data(%d) - server has terminated the connection abnormally\n",
- ret);
+ fprintf(stderr, "*** Error: %s\n", gnutls_strerror(ret));
goto end;
}
} else {
printf("- Peer has closed the TLS connection\n");
goto end;
} else if (ret < 0) {
- fprintf(stderr, "*** Received corrupted data(%d) - server has terminated the connection abnormally\n",
- ret);
+ fprintf(stderr, "*** Error: %s\n", gnutls_strerror(ret));
goto end;
} else if (ret > 0) {
printf("- Received %d bytes: ", ret);
*/
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
-
gnutls_transport_set_ptr( session, sd);
+
/* Perform the TLS handshake
*/
ret = gnutls_handshake( session);
printf("- Peer has closed the TLS connection\n");
goto end;
} else if (ret < 0) {
- fprintf(stderr, "*** Received corrupted data(%d) - server has terminated the connection abnormally\n",
- ret);
+ fprintf(stderr, "*** Error: %s\n", gnutls_strerror(ret));
goto end;
} else if (ret > 0) {
printf("- Received %d bytes: ", ret);
status = gnutls_certificate_verify_peers(session);
if (status == GNUTLS_E_NO_CERTIFICATE_FOUND) {
- printf("No certificate was sent");
+ printf("No certificate was sent\n");
return;
}
if (status & GNUTLS_CERT_INVALID || status & GNUTLS_CERT_NOT_TRUSTED
|| status & GNUTLS_CERT_CORRUPTED || status & GNUTLS_CERT_REVOKED) {
- printf("The certificate is not trusted");
+ printf("The certificate is not trusted\n");
return;
}