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                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to