Hello,

I've been wrestling with a problem we have been having, which I believe to
be to be related to OpenSSL.

It's quite the scenerio - I'll attempt to describe it.

We are using a COM object on NT, to allow a web server (IIS) to use a
bunch of Perl modules, which in turn uses OpenSSL.

The COM object was made using scriptlets where the scripting language is
Perlscript.   When then object is created, it calls an init() method,
which will create an SSL socket.

Everything works perfect the first time the object is created.  The SSL
socket is created and everything works great.

After the COM object is destroyed, and a new one is created - it fails to
recreate it.

After much tedious debugging, it appears to fail during the call to
add_all_algorithms().  Note that this only happens after the first object
was created and destroyed.   It always works the first time.

Our crypto guru here suggested to make sure we are using
CRYPTO_set_mem_functions to ensure memory allocation was being done
right in the Perl side of things.

After adding a block of code to the SSLeay.xs to do this, we still get the
same behaviour.   Here's that code:
----------------------------------------------------------
static void sslmem_init();
static void * ssl_malloc(size_t size);
static void * ssl_calloc(size_t number, size_t size);
static void * ssl_realloc(void *ptr, size_t size);
static void ssl_free(void *ptr);

static
void
sslmem_init()
{
                CRYPTO_set_mem_functions(
                        ssl_malloc,
                        ssl_realloc,
                        ssl_free);

                OpenSSL_add_all_algorithms();
                SSL_load_error_strings();
                BIO_sock_init();

                #ifdef WIN32
                RAND_screen();
                #endif
}

static
void *
ssl_malloc(size_t size)
{
   void *new_ptr;
   New(1, new_ptr, size, char);
   return (new_ptr);
}

static
void *
ssl_calloc(size_t number, size_t size)
{
   void *new_ptr;
   Newz(1, new_ptr, (number*size), char);
   return (new_ptr);
}

static
void *
ssl_realloc(void *ptr, size_t size)
{
   Renew(ptr, size, char);
   return (ptr);
}

static
void
ssl_free(void *ptr)
{
   Safefree(ptr);
}
------------------------------------------------
and we call that in there by using:

BOOT:
sslmem_init();
------------------------------------------------

The sslmem_init method is getting called, as I had some debugging
statements to see where it dies.   Again, it fails when it calls
add_all_algorithms().

If I put some code to only call add_all_algorithms once, and don't call it
in the future the socket fails to be created properly.

Has anyone encountered something like this before?   Of course everything
works perfectly when this application is used on Linux with Apache.   It's
the NT side of things that are giving us the most trouble.

- dan




______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to