Hi,
I'm trying to save a session to a buffer, like it is proposed in several articles, using i2d_SSL_SESSION. However, when trying to restore the session from the ASN1 buffer it immediately returns with an error. from what I learned from the various articles and samples I feel that the following code snippet should restore what is available in "sess" into "sess2": int len; unsigned char *pp; int rc; SSL_SESSION *sess=NULL, *sess2=NULL; sess = SSL_get1_session( ssl ); if( sess ) { len = i2d_SSL_SESSION( sess, NULL ); fprintf( stderr, "SESS: len=%d\n", len ); pp = (unsigned char *)malloc( len ); rc = i2d_SSL_SESSION( sess, &pp ); fprintf( stderr, "SESS: converted to asn1, rc=%d\n", rc ); sess2 = d2i_SSL_SESSION( NULL, &pp, len ); fprintf( stderr, "SESS: new sess2=%x\n", sess2 ); } however, the result I keep getting is a NULL pointer and a the ssl error message: SSL error: 218525757 (error:0D06703D:asn1 encoding routines:a2i_ASN1_STRING:expecting an asn1 sequence) in ssl_asn1.c line 242: "address=135554540 offset=0". there's not much comprehensive documentation about this topic and I'm sure I misunderstand something ... but "WHAT" do I misunderstand is the question??? is there anyone out there who got this session saving stuff to work ... ??? Klaus. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [hidden email] Automated List Manager [hidden email] |
On Mon, Jul 04, 2005, Klaus Thurnhofer wrote:
> Hi, > > I'm trying to save a session to a buffer, like it is proposed in several > articles, using i2d_SSL_SESSION. However, when trying to restore the session > from the ASN1 buffer it immediately returns with an error. > > from what I learned from the various articles and samples I feel that the > following code snippet should restore what is available in "sess" into > "sess2": > > int len; > unsigned char *pp; > int rc; > SSL_SESSION *sess=NULL, *sess2=NULL; > > sess = SSL_get1_session( ssl ); > if( sess ) > { > len = i2d_SSL_SESSION( sess, NULL ); > fprintf( stderr, "SESS: len=%d\n", len ); > pp = (unsigned char *)malloc( len ); > rc = i2d_SSL_SESSION( sess, &pp ); > fprintf( stderr, "SESS: converted to asn1, rc=%d\n", rc ); > > sess2 = d2i_SSL_SESSION( NULL, &pp, len ); > fprintf( stderr, "SESS: new sess2=%x\n", sess2 ); > } > > > however, the result I keep getting is a NULL pointer and a the ssl error > message: > > > there's not much comprehensive documentation about this topic and I'm sure I > misunderstand something ... but "WHAT" do I misunderstand is the question??? > > is there anyone out there who got this session saving stuff to work ... ??? > You aren't calling the i2d function correctly. This is dealt with in the FAQ. Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Funding needed! Details on homepage. Homepage: http://www.drh-consultancy.demon.co.uk ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [hidden email] Automated List Manager [hidden email] |
Free forum by Nabble | Edit this page |