[Help-gnutls] Restore gnutls session after execvp - possible?

FlashCode flashcode at flashtux.org
Sun Dec 11 16:58:41 CET 2005


I'm developing an IRC client called WeeChat
I'm adding a new feature: /upgrade command, which does an execvp() of
weechat, without closing connections to servers (sockets are still
open after execvp).

For some servers, user may connect thru gnutls (SSL), and I need to save
session in file when upgrading, then restore it when starting new

Is it possible to do that with gnutls today?

I saw an example in the doc, but situation is not exactly the same,
socket is reopen after close, then gnutls session reloaded.
In my case, socket is not closed.

I tried something like that :

1. quit weechat without closing sockets, and do that for gnutls:

 - for each gnutls server:
    gnutls_session_get_data (ptr_server->gnutls_sess, NULL,
    session_data = malloc (session_size);
    gnutls_session_get_data (server->gnutls_sess, session_data,
    /* save session data to session file */
    gnutls_bye (server->gnutls_sess, GNUTLS_SHUT_RDWR);
    gnutls_deinit (server->gnutls_sess);
 - global:
    gnutls_certificate_free_credentials (gnutls_xcred);

2. start new weechat via execvp (load session file):

 - global:
    gnutls_global_init ();
    gnutls_certificate_allocate_credentials (&gnutls_xcred);
    gnutls_certificate_set_x509_trust_file (gnutls_xcred,
        "ca.pem", GNUTLS_X509_FMT_PEM);
 - for each gnutls server:
    gnutls_set_default_priority (server->gnutls_sess);
    gnutls_certificate_type_set_priority  (server->gnutls_sess,
    gnutls_credentials_set (server->gnutls_sess,
    /* read session & size (internal stuff not shown here) */
    gnutls_session_set_data (server->gnutls_sess,
                             session_data, session_size);
    gnutls_transport_set_ptr (server->gnutls_sess,
    if (gnutls_handshake (server->gnutls_sess) < 0)
        printf ("handshake failed\n");

Problem: the handshake always failed when restoring weechat session.

Thank you in advance, any help appreciated.

Cordialement / Best regards

Web: http://www.flashtux.org - email: flashcode at flashtux.org
IRC: FlashCode at irc.freenode.net - Jabber: flashcode at jabber.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: </pipermail/attachments/20051211/cb28b867/attachment.pgp>

More information about the Gnutls-help mailing list