[noPoll] Server PSK Callback via nopoll_ctx_set_ssl_context_creator

Chris Buchter buchtcj en gmail.com
Jue Ene 21 18:54:59 CET 2016


Hi Everyone,

I am trying to set up custom callbacks using the
function nopoll_ctx_set_ssl_context_creator.Here is what I have:

In Main:
noPollCtx *np_ctx = nopoll_ctx_new();
nopoll_ctx_set_ssl_context_creator(np_ctx,
(noPollSslContextCreator)my_ssl_ctx_creator, NULL);
noPollConn *listener = nopoll_listener_tls_new_opts(np_ctx,opts, "0.0.0.0",
"8091");
if(! nopoll_conn_is_ok(listener)){printf("Error\n");return 1;}
nopoll_ctx_set_on_msg(np_ctx, (noPollOnMessageHandler)message_handler,
NULL);
nopoll_loop_wait(np_ctx, 0);

------------------------------------------------------------------------------------------------------------------------------------------

SSL_CTX * my_ssl_ctx_creator (noPollCtx * ctx, noPollConn * conn,
noPollConnOpts * opts, nopoll_bool is_client, noPollPtr user_data)
{
    printf("ctx_creator\n");
    SSL_CTX *ssl_ctx = initialize_ssl();
    return ssl_ctx;
}

SSL_CTX* initialize_ssl()
{
    const SSL_METHOD *method;
    SSL_CTX *ctx;
    SSL_library_init();
    SSL_load_error_strings();
    OpenSSL_add_all_algorithms();
    method = TLSv1_server_method();
    ctx = SSL_CTX_new(method);
    SSL_CTX_set_psk_server_callback(ctx, psk_server_cb);
    SSL_CTX_set_verify(ctx,
SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT|SSL_VERIFY_CLIENT_ONCE,
cert_server_cb);
    printf("setup certs\n");
    SSL_CTX_use_certificate_file(ctx, "./cert.pem", SSL_FILETYPE_PEM);
    SSL_CTX_use_PrivateKey_file(ctx, "./key.pem", SSL_FILETYPE_PEM);
    if(SSL_CTX_set_cipher_list(ctx, ciphers) == 0)
    {
        printf("Fail to select ciphers\n");
        exit(1);
    }
    if(ctx == NULL)
    {
        printf("CTX Error\n");
        exit(1);
    }
    return ctx;
}

Unfortunely, noPoll does not hit my callbacks when performing the
handshake....

Any help?

Thanks
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20160121/2a27b5d7/attachment.html>


Más información sobre la lista de distribución noPoll