Hi,

 

I've made a small sample based on OpenSSL which creates a new key and then
makes a certificate request.

Everything works fine on XP but the same code crashes on VISTA

 

OpenSSL version: openssl-0.9.8h

Build with VS 2008 (everything build with success and all tests passed.)

 

 

The crash comes in the PEM_write_X509_REQ()

 

And more specifically in 

static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)

{

.

 

#if defined(OPENSSL_SYS_WINDOWS)

            int fd = fileno((FILE*)ptr);

            if (num & BIO_FP_TEXT)

                  _setmode(fd,_O_TEXT);

            else

                  _setmode(fd,_O_BINARY); <<<<<<<<<<<<<<< crash (fd = 3)

 

 

Anyone any ideas?

 

Thanks,

 

 

 

 

 

main (int argc, char *argv[])

{

.

 

   OPENSSL_Applink() ;

 

   OpenSSL_add_all_algorithms ();

   ERR_load_crypto_strings ();

 

   if ((pkey=EVP_PKEY_new()) == NULL)

   {

      int_error ("Failed to create EVP_PKEY object");

   }

 

   rsa=RSA_generate_key(1024, RSA_F4, callback, NULL);

   if (!EVP_PKEY_assign_RSA(pkey,rsa))

   {

      int_error ("Failed to assign RSA key");

   }

 

   /* create a new request and add the key to it */

   if (!(req = X509_REQ_new ()))

   {

      int_error ("Failed to create X509_REQ object");

   }

   X509_REQ_set_pubkey (req, pkey);

 

   /* assign the subject name */

   if (!(subj = X509_NAME_new ()))

   {

      int_error ("Failed to create X509_NAME object");

   }

 

.

 

 

   fp = fopen (REQ_FILE, "w");

   if (fp==NULL)

   {

      int_error ("Error writing to request file");

   }

   if (PEM_write_X509_REQ (fp, req) != 1)

   {

      int_error ("Error while writing request");

   }

   fclose (fp);

 

.

 

 

Reply via email to