Your stack trace points to a release version of MS libraries. Please ensure
that you run the release version of your program.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Matthias
Sent: Wednesday, February 15, 2006 4:24 PM
To: openssl-users@openssl.org
Subject: Re: function PEM_read_RSAPrivateKey not returning


Hi again

I downloaded from slproweb at 9. February 2006 and the file
is called "Win32OpenSSL-v0.9.8a.exe". I didn't have any
OpenSSL stuff on my computer before, so even no "old things"
lieing around on the harddisc.

If I run the program in VS .net 2003 v7.1.3088 with "Start F5"
the program seems to "freeze" at PEM_read_RSAPrivateKey,
consumes 100% usage of one CPU (I have a Hyperthreading so
I see 50% CPU usage in task manager) and when I press
"Break All" in the Debugger I get the following call stack:

---------- snip ----------

msvcrt.dll!77c12b9f()
ntdll.dll!7c9206eb()
ntdll.dll!7c97d886()
ntdll.dll!7c959d18()
ntdll.dll!7c92b686()
ntdll.dll!7c936a44()
ntdll.dll!7c936abe()
ntdll.dll!7c936abe()
ntdll.dll!7c97cde9()
ntdll.dll!7c97e0f0()
ntdll.dll!7c97e0d4()
ntdll.dll!7c92b5f4()
ntdll.dll!7c92b686()
ntdll.dll!7c936abe()
ntdll.dll!7c97cde9()
ntdll.dll!7c97e0f0()
ntdll.dll!7c95a1f5()
ntdll.dll!7c92b5f4()
ntdll.dll!7c92b686()
kernel32.dll!7c81cb8e()
kernel32.dll!7c81cbcb()
ntdll.dll!7c91e3ed()
ntdll.dll!7c9232f8()
kernel32.dll!7c81cb8e()
kernel32.dll!7c81cbcb()
msvcrt.dll!77c0f962()
msvcrt.dll!77bfc3ce()
libeay32.dll!1000101e()
libeay32.dll!1000120c()
libeay32.dll!1003f487()
libeay32.dll!1003d627()
libeay32.dll!10068404()
msvcr71d.dll!_write_lk(int fh=1, const void * buf=0x00000fa0, unsigned
int cnt=270647770)  Line 234 + 0x8      C
msvcr71d.dll!_write(int fh=1244344, const void * buf=0x1021b45c,
unsigned int cnt=1)  Line 87 + 0x9      C
msvcr71d.dll!_unlock_fhandle(int fh=1244344)  Line 477  C
003e1fb8()
msvcr71d.dll!_write(int fh=1244392, const void * buf=0x00000001,
unsigned int cnt=270542996)  Line 87 + 0x9      C
msvcr71d.dll!_flsbuf(int ch=271042648, _iobuf * str=0x1024755c)  Line
180 + 0x11      C
msvcr71d.dll!fputc(int ch=10, _iobuf * str=0x1027c858)  Line 56 + 0x9   C
msvcr71d.dll!_tsopen_lk(int * punlock_flag=0x0000000a, int *
pfh=0x1027c858, const char * path=0x0012fdb8, int oflag=273198671, int
shflag=1244426, int pmode=273199175)  Line 414 + 0xd    C
msvcp71d.dll!std::_Fputc<char>(char _Byte='<STRANGEBOXHERE>', _iobuf *
_File=0x1048b047)  Line 69 + 0xf        C++
msvcp71d.dll!std::basic_filebuf<char,std::char_traits<char>
 >::overflow(int _Meta=268693911)  Line 206 + 0x19      C++
msvcrt.dll!77bffc5d()
libeay32.dll!1003d861()
libeay32.dll!1006a15a()
libeay32.dll!1006a4d6()
libeay32.dll!10068cf8()
CryptoOpenSSLTest5.exe!main(int argc=1, char * * argv=0x003e5a40)  Line
82 + 0xf        C++
CryptoOpenSSLTest5.exe!mainCRTStartup()  Line 398 + 0x11        C
kernel32.dll!7c816d4f()
ntdll.dll!7c925b4f()
kernel32.dll!7c8399f3()

---------- snap ----------

That "CryptoOpenSSLTest5.exe!main [...] Line 82" is the call of
PEM_read_RSAPrivateKey. "<STRANGEBOXHERE>" is that strange box
for undisplayable characters.

Thanks for the help,
Matthias



Kyle Hamilton wrote:

> One of the most important things about this is, "when did you obtain
> the installer from slproweb.com"?  It's difficult to figure out if
> it's older, or a problem in a very recent build, or what.
>
> Did you attach a debugger to the program and examine it to see what
> might be looping?
>
> (In the meantime, I'm going to try this with VC++ 2005, 8.0).
>
> -Kyle H
>
> On 2/15/06, Matthias <[EMAIL PROTECTED]> wrote:
>> Good day everyone!
>>
>> I do have the problem that the OpenSSL function "PEM_read_RSAPrivateKey"
>> does nothing, not even returning. Since I can not find any more hints
>> in the net I am asking here for help. I wrote a minimalistic example
>> program and hope somebody can give me some advice based on that.
>>
>> I am using Visual Studio .net 2003 v7.1.3088 on Windows XP Pro SP 2.
>>
>> For OpenSSL I am using Win32 OpenSSL v0.9.8a, the precompiled and
>> installer-packed binaries you can find under
>> http://www.slproweb.com/products/Win32OpenSSL.html
>>
>> What I did:
>>
>> Visual Studio Application Wizard: Win32 Console Application,
>> starting as empty project
>> added Additional Include Directories: "..\openssl\include"
>> added Additional Library Directories: "..\openssl\lib\vc"
>> (NOT "..\openssl\lib\vc\static" !)
>> added Additional Dependencies: "libeay32.lib ssleay32.lib"
>> set Runtime Library on "Multi-threaded Debug DLL (/MDd)" and
>> "Multi-threaded DLL (/MD)"
>> copied "applink.c" into project directory and added to VS project
>> created new file "example.cpp" and added to VS project
>>
>> -------------------- snip --------------------
>>
>> // SSL
>> #include "openssl/ssl.h"
>> #include "openssl/rand.h"
>> #include "openssl/err.h"
>> #include "openssl/rsa.h"
>>
>> // STD
>> #include <iostream>
>> #include <string>
>> #include <iomanip>
>> using namespace std;
>>
>> // TCHAR
>> #include <tchar.h>
>>
>> int _tmain(int argc, _TCHAR* argv[])
>> {
>>    // initialization
>>    {
>>      SSL_load_error_strings();
>>
>>      SSL_library_init();
>>      // note: replaces OpenSSL_add_all_algorithms() since 0.9.8a
>>
>>      cout << "Seed random number generator..." << endl;
>>      const char SeedBuffer[16] = "123456789ABCDEF";
>>      RAND_seed(SeedBuffer, 16);
>>    }
>>
>>    // generate and write keys
>>    {
>>      cout << "Generate RSA key..." << endl;
>>      RSA* pRSA = RSA_generate_key(1024, 65537, NULL, NULL);
>>      if (pRSA == NULL)
>>      {
>>        cout
>>          << "RSA_generate_key failed: "
>>          << ERR_get_error()
>>          << endl;
>>        return false;
>>      }
>>
>>      cout << "Size: " << RSA_size(pRSA) * 8 << " Bit" << endl;
>>
>>      FILE* pPrivateKeyFile = fopen("RSAPrivateKey.txt", "w");
>>      if (pPrivateKeyFile == NULL)
>>      {
>>        cout << "fopen failed" << endl;
>>        return 1;
>>      }
>>
>>      cout << "Write private key file..." << endl;
>>      if (PEM_write_RSAPrivateKey(
>>        pPrivateKeyFile, pRSA, NULL, NULL, 0, NULL, NULL) == 0)
>>      {
>>        cout
>>          << "PEM_write_RSAPrivateKey failed: "
>>          << ERR_get_error()
>>          << endl;
>>        return 1;
>>      }
>>
>>      fclose(pPrivateKeyFile);
>>
>>      // note: file "RSAPrivateKey.txt" now exists, is plaintext
>>      // and obviously contains a key
>>
>>    }
>>
>>    // read keys
>>    {
>>      FILE* pPrivateKeyFile = fopen("RSAPrivateKey.txt", "r");
>>      if (pPrivateKeyFile == NULL)
>>      {
>>        cout << "fopen failed" << endl;
>>        return 1;
>>      }
>>
>>      cout << "Read private key file..." << endl;
>>      RSA* pPrivateKeyRSA = PEM_read_RSAPrivateKey(
>>        pPrivateKeyFile, NULL, NULL, NULL);
>>
>>      // !!!!! program never comes here !!!!!
>>
>>      // note: I tried every combination of callback function
>>      // for the password but the program never got there, too
>>
>>      if (pPrivateKeyRSA == NULL)
>>      {
>>        cout
>>          << "PEM_read_RSAPrivateKey failed: "
>>          << ERR_get_error()
>>          << endl;
>>        return 1;
>>      }
>>
>>      fclose(pPrivateKeyFile);
>>
>>      cout
>>        << "Size: " << RSA_size(pPrivateKeyRSA) * 8 << " Bit"
>>        << endl;
>>    }
>>
>>    cout << "Done." << endl;
>>    return 0;
>> }
>>
>> -------------------- snap --------------------
>>
>> Thanks,
>> Matthias
>>
>> ______________________________________________________________________
>> OpenSSL Project                                 http://www.openssl.org
>> User Support Mailing List                    openssl-users@openssl.org
>> Automated List Manager                           [EMAIL PROTECTED]
>>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           [EMAIL PROTECTED]
>
>

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

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

Reply via email to