[Help-gnutls] Restore gnutls session after execvp - possible?
FlashCode
flashcode at flashtux.org
Sun Dec 11 16:58:41 CET 2005
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.
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
-------------- 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