Codebase list libcrypt-ssleay-perl / 8524182
Clean up info callback used when debugging is enabled A. Sinan Unur 9 years ago
2 changed file(s) with 43 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
1717 bootstrap Crypt::SSLeay;
1818 };
1919
20
2120 use Crypt::SSLeay::X509;
2221
2322 # A xsupp bug made this necessary
2121 #define PERL5 1
2222 #endif
2323
24 #include <openssl/ssl.h>
24 #include <openssl/bio.h>
2525 #include <openssl/crypto.h>
2626 #include <openssl/err.h>
27 #include <openssl/pkcs12.h>
2728 #include <openssl/rand.h>
28 #include <openssl/pkcs12.h>
29 #include <openssl/ssl.h>
2930
3031 #define CRYPT_SSLEAY_free OPENSSL_free
3132
4344
4445 #define CRYPT_SSL_CLIENT_METHOD SSLv23_client_method()
4546
46 static void InfoCallback(const SSL *s,int where,int ret)
47 {
48 const char *str;
49 int w;
50
51 w = where & ~SSL_ST_MASK;
52
53 if(w & SSL_ST_CONNECT)
54 str="SSL_connect";
55 else if(w & SSL_ST_ACCEPT)
56 str="SSL_accept";
57 else
58 str="undefined";
59
60 if(where & SSL_CB_LOOP) {
61 fprintf(stderr,"%s:%s\n",str,SSL_state_string_long(s));
47 static void
48 info_callback(const SSL *s, int where, int ret) {
49 BIO *bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
50 int w = where & ~SSL_ST_MASK;
51 const char *mode = (w & SSL_ST_CONNECT) ? "SSL_connect"
52 : (w & SSL_ST_ACCEPT) ? "SSL_accept"
53 : "unknown"
54 ;
55
56 if (where & SSL_CB_LOOP) {
57 BIO_printf(bio_err, "%s: %s\n", mode, SSL_state_string_long(s));
58 return;
6259 }
63 else if(where & SSL_CB_ALERT) {
64 str=(where & SSL_CB_READ)?"read":"write";
65 fprintf(stderr,"SSL3 alert %s:%s:%s\n",str,
66 SSL_alert_type_string_long(ret),
67 SSL_alert_desc_string_long(ret));
68 }
69 else if(where & SSL_CB_EXIT) {
70 if(ret == 0)
71 fprintf(stderr,"%s:failed in %s\n",str,SSL_state_string_long(s));
72 else if (ret < 0)
73 fprintf(stderr,"%s:error in %s\n",str,SSL_state_string_long(s));
74 }
60
61 if (where & SSL_CB_ALERT) {
62 BIO_printf(
63 bio_err, "SSL/TLS alert %s: %s: %s\n",
64 (where & SSL_CB_READ) ? "read" : "write",
65 SSL_alert_type_string_long(ret),
66 SSL_alert_desc_string_long(ret)
67 );
68 return;
7569 }
70
71 if (where & SSL_CB_EXIT) {
72 if (ret == 0) {
73 BIO_printf(
74 bio_err, "%s: failed in %s\n",
75 mode, SSL_state_string_long(s)
76 );
77 return;
78 }
79 if (ret < 0) {
80 BIO_printf(
81 bio_err, "%s:error in %s\n",
82 mode, SSL_state_string_long(s)
83 );
84 return;
85 }
86 }
87 }
88
7689
7790 MODULE = Crypt::SSLeay PACKAGE = Crypt::SSLeay
7891