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

Simon Josefsson jas at extundo.com
Sun Dec 11 19:51:06 CET 2005


FlashCode <flashcode at flashtux.org> writes:

> Hi,
>
> I'm developing an IRC client called WeeChat
> (http://weechat.flashtux.org).
> 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
> process.
>
> 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.

How do you achieve that?  I thought you had to close sockets and
re-open them in a new process.

I don't know how to achieve what you want in GnuTLS, but I don't know
how to achieve what you already do either (exec another process and
inherit the open socket) so I may likely be missing something.
Perhaps others know more.

> 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_size);
>     session_data = malloc (session_size);
>     gnutls_session_get_data (server->gnutls_sess, session_data,
>                              &session_size);
>     /* 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);
>     gnutls_global_deinit();
>
> 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,
>                                            cert_type_prio);
>     gnutls_credentials_set (server->gnutls_sess,
>                             GNUTLS_CRD_CERTIFICATE,
>                             gnutls_xcred);
>     /* 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,
>                               (gnutls_transport_ptr)
> 			      server->sock);
>     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
> Sebastien.
>
> Web: http://www.flashtux.org - email: flashcode at flashtux.org
> IRC: FlashCode at irc.freenode.net - Jabber: flashcode at jabber.org
> _______________________________________________
> Help-gnutls mailing list
> Help-gnutls at gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnutls





More information about the Gnutls-help mailing list