Skip to content

Commit

Permalink
openssl: Use SSL_CTX_set_msg_callback and SSL_CTX_set_msg_callback_arg
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bprodoehl authored and bagder committed May 19, 2015
1 parent 265f83a commit a393d64
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/vtls/openssl.c
Expand Up @@ -1537,15 +1537,16 @@ static const char *tls_rt_type(int type)
* Our callback from the SSL/TLS layers.
*/
static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
const void *buf, size_t len, const SSL *ssl,
struct connectdata *conn)
const void *buf, size_t len, SSL *ssl,
void *userp)
{
struct SessionHandle *data;
const char *msg_name, *tls_rt_name;
char ssl_buf[1024];
char unknown[32];
int msg_type, txt_len;
const char *verstr;
struct connectdata *conn = userp;

if(!conn || !conn->data || !conn->data->set.fdebug ||
(direction != 0 && direction != 1))
Expand Down Expand Up @@ -1805,16 +1806,9 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)

#ifdef SSL_CTRL_SET_MSG_CALLBACK
if(data->set.fdebug && data->set.verbose) {
/* the SSL trace callback is only used for verbose logging so we only
inform about failures of setting it */
if(!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK,
(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");
}
/* the SSL trace callback is only used for verbose logging */
SSL_CTX_set_msg_callback(connssl->ctx, ssl_tls_trace);
SSL_CTX_set_msg_callback_arg(connssl->ctx, conn);
}
#endif

Expand Down

0 comments on commit a393d64

Please sign in to comment.