[Help-gnutls] GnuTLS and Qt

Nikos Mavrogiannopoulos nmav at gnutls.org
Sun Nov 4 13:28:13 CET 2007


On Sunday 04 November 2007, Ian Cullinan wrote:

> I'm trying to get to grips with GnuTLS and Qt, so what I'm doing is
> building a very simple "chat" program. I've defined:
[...]
> struct gcry_thread_cbs gcry_threads_qt = {
>  GCRY_THREAD_OPTION_USER, gcry_qthread_init, gcry_qmutex_init,
>  gcry_qmutex_destroy, gcry_qmutex_lock, gcry_qmutex_unlock,
>  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};

These should be sufficient to allow exclusive access to the random number 
generator.

> and I'm calling
>        gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_qt);
>        gnutls_global_init();
> from the constructor of my main window. Which leads me to my first
> question(s): do I need to do that? Or does it not really matter, even
> though Qt make pretty heavy use of threads? Have I done something
> wrong there? Should I be providing something for the select, waitpid,
> accept, etc parts of that struct?

No.


> On any incoming connection (from my own code, or form gnutls-cli, I
> get "A TLS packet with unexpected length was received." Nothing
> appears in my console, so I don't think QTcpSocket is giving errors.
> What am I missing here? I've copied the "Echo Server with Anonymous
> Authentication" example almost exactly. Am I taking the right approach
> by wrapping QMutex and QTcpSocket?

A way to debug this would be by checking the TLS packets exchanged using
wireshark (ethereal) or ssldump.

You should also enable the gnutls debugging options using
gnutls_global_set_log_function() and gnutls_global_set_log_level() to see 
where this error occured.


regards,
Nikos





More information about the Gnutls-help mailing list