Commit 4cf65783f1c6b21cfe2fbbf29c6cc322613e6711
1 parent
80abb883
Exists in
master
and in
5 other branches
Incluindo dump do certificado no trace de comunicação para facilitar o debug de SSL
Showing
1 changed file
with
23 additions
and
0 deletions
Show diff stats
src/lib3270/telnet.c
| @@ -776,6 +776,7 @@ static void ssl_negotiate(H3270 *hSession) | @@ -776,6 +776,7 @@ static void ssl_negotiate(H3270 *hSession) | ||
| 776 | char buffer[4096]; | 776 | char buffer[4096]; |
| 777 | int alg_bits = 0; | 777 | int alg_bits = 0; |
| 778 | const SSL_CIPHER * cipher = SSL_get_current_cipher(hSession->ssl_con); | 778 | const SSL_CIPHER * cipher = SSL_get_current_cipher(hSession->ssl_con); |
| 779 | + X509 * peer = SSL_get_peer_certificate(hSession->ssl_con); | ||
| 779 | 780 | ||
| 780 | trace_dsn(hSession,"TLS/SSL negotiated connection complete. Connection is now secure.\n"); | 781 | trace_dsn(hSession,"TLS/SSL negotiated connection complete. Connection is now secure.\n"); |
| 781 | 782 | ||
| @@ -786,6 +787,28 @@ static void ssl_negotiate(H3270 *hSession) | @@ -786,6 +787,28 @@ static void ssl_negotiate(H3270 *hSession) | ||
| 786 | SSL_CIPHER_get_version(cipher), | 787 | SSL_CIPHER_get_version(cipher), |
| 787 | alg_bits, | 788 | alg_bits, |
| 788 | SSL_get_verify_result(hSession->ssl_con)); | 789 | SSL_get_verify_result(hSession->ssl_con)); |
| 790 | + | ||
| 791 | + if(peer) | ||
| 792 | + { | ||
| 793 | + BIO * out = BIO_new(BIO_s_mem()); | ||
| 794 | + unsigned char * data; | ||
| 795 | + unsigned char * text; | ||
| 796 | + int n; | ||
| 797 | + | ||
| 798 | + X509_print(out,peer); | ||
| 799 | + | ||
| 800 | + n = BIO_get_mem_data(out, &data); | ||
| 801 | + text = (unsigned char *) malloc (n+1); | ||
| 802 | + text[n] ='\0'; | ||
| 803 | + memcpy(text,data,n); | ||
| 804 | + | ||
| 805 | + trace_dsn(hSession,"TLS/SSL peer certificate:\n%s\n",text); | ||
| 806 | + | ||
| 807 | + free(text); | ||
| 808 | + BIO_free(out); | ||
| 809 | + X509_free(peer); | ||
| 810 | + | ||
| 811 | + } | ||
| 789 | } | 812 | } |
| 790 | 813 | ||
| 791 | if(!SSL_get_verify_result(hSession->ssl_con)) | 814 | if(!SSL_get_verify_result(hSession->ssl_con)) |