boolean tls_print_error(char* func, SSL* connection, int value) { switch (SSL_get_error(connection, value)) { case SSL_ERROR_ZERO_RETURN: printf("%s: Server closed TLS connection\n", func); return true; case SSL_ERROR_WANT_READ: printf("SSL_ERROR_WANT_READ\n"); return false; case SSL_ERROR_WANT_WRITE: printf("SSL_ERROR_WANT_WRITE\n"); return false; case SSL_ERROR_SYSCALL: printf("%s: I/O error\n", func); tls_errors(func); return true; case SSL_ERROR_SSL: printf("%s: Failure in SSL library (protocol error?)\n", func); tls_errors(func); return true; default: printf("%s: Unknown error\n", func); tls_errors(func); return true; } }
BOOL tls_print_error(char* func, SSL* connection, int value) { switch (SSL_get_error(connection, value)) { case SSL_ERROR_ZERO_RETURN: fprintf(stderr, "%s: Server closed TLS connection\n", func); return TRUE; case SSL_ERROR_WANT_READ: fprintf(stderr, "%s: SSL_ERROR_WANT_READ\n", func); return FALSE; case SSL_ERROR_WANT_WRITE: fprintf(stderr, "%s: SSL_ERROR_WANT_WRITE\n", func); return FALSE; case SSL_ERROR_SYSCALL: fprintf(stderr, "%s: I/O error: %s (%d)\n", func, strerror(errno), errno); tls_errors(func); return TRUE; case SSL_ERROR_SSL: fprintf(stderr, "%s: Failure in SSL library (protocol error?)\n", func); tls_errors(func); return TRUE; default: fprintf(stderr, "%s: Unknown error\n", func); tls_errors(func); return TRUE; } }