[noPoll] Server PSK Callback via nopoll_ctx_set_ssl_context_creator

Francis Brosnan Blázquez francis en aspl.es
Jue Ene 21 19:19:44 CET 2016


Hi Chris,

I see no error in your code :-?

Calling to nopoll_ctx_set_ssl_context_creator, configures internal
handlers that are called by the listener by the line 4011 at
https://github.com/ASPLes/nopoll/blob/master/src/nopoll_conn.c

..which in turns calles your handler at the line 466 in the same file..

Do you have a ready to use (make enabled) working example to test? 

Best Regards,


> 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
> 
> _______________________________________________
> noPoll mailing list
> noPoll en lists.aspl.es
> http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll


-- 
Francis Brosnan Blázquez - ASPL
91 134 14 22 - 91 134 14 45 - 91 116 07 57

http://aspl.es
http://asplhosting.com
http://twitter.com/aspl_es
http://twitter.com/asplhosting

AVISO LEGAL

Este mensaje se dirige exclusivamente a su destinatario. Los datos
incluidos en el presente correo son confidenciales y sometidos a secreto
profesional, se prohíbe divulgarlos, en virtud de las leyes vigentes. Si
usted no lo es y lo ha recibido por error o tiene conocimiento del mismo
por cualquier motivo, le rogamos que nos lo comunique por este medio y
proceda a destruirlo o borrarlo.

En virtud de lo dispuesto en la Ley Orgánica 15/1999, de 13 de
diciembre, de Protección de Datos de Carácter Personal, le informamos de
que sus datos de carácter personal, recogidos de fuentes accesibles al
público o datos que usted nos ha facilitado previamente, proceden de
bases de datos propiedad de Advanced Software Production Line, S.L.
(ASPL). No obstante, usted puede ejercitar sus derechos de acceso,
rectificación, cancelación y oposición dispuestos en la mencionada Ley
Orgánica, notificándolo por escrito a:
ASPL - Protección Datos, C/Antonio Suárez 10 A-102, 28802, Alcalá de
Henares (Madrid).
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20160121/f47e66f8/attachment.html>


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