1
0
mirror of https://github.com/moparisthebest/curl synced 2024-10-31 15:45:12 -04:00

openssl: Use SSL_CTX_set_msg_callback and SSL_CTX_set_msg_callback_arg

BoringSSL removed support for direct callers of SSL_CTX_callback_ctrl
and SSL_CTX_ctrl, so move to a way that should work on BoringSSL and
OpenSSL.

re #275
This commit is contained in:
Brian Prodoehl 2015-05-19 11:10:28 -04:00 committed by Daniel Stenberg
parent 265f83a9f0
commit a393d64456

View File

@ -1537,8 +1537,8 @@ static const char *tls_rt_type(int type)
* Our callback from the SSL/TLS layers. * Our callback from the SSL/TLS layers.
*/ */
static void ssl_tls_trace(int direction, int ssl_ver, int content_type, static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
const void *buf, size_t len, const SSL *ssl, const void *buf, size_t len, SSL *ssl,
struct connectdata *conn) void *userp)
{ {
struct SessionHandle *data; struct SessionHandle *data;
const char *msg_name, *tls_rt_name; const char *msg_name, *tls_rt_name;
@ -1546,6 +1546,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
char unknown[32]; char unknown[32];
int msg_type, txt_len; int msg_type, txt_len;
const char *verstr; const char *verstr;
struct connectdata *conn = userp;
if(!conn || !conn->data || !conn->data->set.fdebug || if(!conn || !conn->data || !conn->data->set.fdebug ||
(direction != 0 && direction != 1)) (direction != 0 && direction != 1))
@ -1805,16 +1806,9 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
#ifdef SSL_CTRL_SET_MSG_CALLBACK #ifdef SSL_CTRL_SET_MSG_CALLBACK
if(data->set.fdebug && data->set.verbose) { if(data->set.fdebug && data->set.verbose) {
/* the SSL trace callback is only used for verbose logging so we only /* the SSL trace callback is only used for verbose logging */
inform about failures of setting it */ SSL_CTX_set_msg_callback(connssl->ctx, ssl_tls_trace);
if(!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK, SSL_CTX_set_msg_callback_arg(connssl->ctx, conn);
(void (*)(void))ssl_tls_trace)) {
infof(data, "SSL: couldn't set callback!\n");
}
else if(!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0,
conn)) {
infof(data, "SSL: couldn't set callback argument!\n");
}
} }
#endif #endif