From: "Dave Thompson" <dave.thomp...@princetonpayments.com>
To be clear: you are building OpenSSL *and* your app(s) with VC05?
Yes.
That should indeed work for release. Check your ms\nt[dll].mak
and you should see /MD on everything.
It works for the pkread.c sample in release build. My real application fails
silently in release build (without the crash I see in debug build), so of
course there's something wrong in the real application, so I need to debug
it, so I need the debug build working as well. Because the debug build
failed in the real application I tried the debug build of pkread.c as well,
and that failed too.
For debug, you need to generate and use a different .mak file;
where you see the lines in do_{ms,masm,nasm}.bat that say
perl util\mk1mf.pl (options) VC-WIN32 >makefile
either add lines with 'debug' added to the options part
and different makefiles (I use ntdbg.mak ntdlldbg.mak),
or just do those one or two command lines manually.
nmake the resulting .mak files and have your app debug build
use out32[dll].dbg\* instead of out32[dll]\*.
OK, I've done that, I'm now trying the pkread.c sample in debug build again.
It fails at the same point, the difference now being that the libeay32.dll
function names are shown (rather than just addresses) in the stack
backtrace. I can't persuade VS2005 to show me the source code, even though
it's apparently claiming to have picked up the .pdb file OK.
msvcr80d.dll!_setmode(int fh=0x00000003, int mode=0x00008000) Line 58 +
0x46 bytes C
libeay32.dll!_BIO_s_file() + 0x3dc bytes C
libeay32.dll!_BIO_ctrl() + 0xa0 bytes C
libeay32.dll!_ASN1_item_d2i_fp() + 0x54 bytes C
libeay32.dll!_d2i_PKCS12_fp() + 0x16 bytes C
test.exe!main(int argc=0x00000001, char * * argv=0x003d4ee8) Line 32 +
0xb bytes C
Trying to follow that through the sources myself it doesn't make any sense
to me - the BIO_s_file I've found, in bss_file.c, simply returns a pointer,
it doesn't make any call to setmode or anything else. OK ... looking at the
disassembly that's because there's something about the debug information
that's confused VS2005, it's not actually BIO_s_file that's being called,
it's several functions later, looks like file_ctrl. Why doesn't the debugger
know about it? Has the debug build cleverly managed to run in a non-standard
fashion that excludes static symbols? (- I remember compilers used to do
that sort of thing in the 1970s). So, obviously, there's something seriously
wrong with the debug build. As also witnessed by I can't trace into
d2i_PKCS12_fp, which might have been helpful.
Thus I'm not really any further on with the debug version, as it was
"clearly" file_ctrl that was calling setmode anyway, because nothing else
does.
(snip)
And I'd be surprised if a lot use _fp routines.
You certainly don't need them for SSL/TLS protocol,
which I consider OpenSSL's strongest benefit.
I'm wanting to do SSL/TLS. Which means I need a certificate and a private
key. I've been given them in a PKCS#12 file. According to the O'Reilly book
you read that by calling d2i_PKCS12_fp followed by PKCS12_parse, which is
exactly what the pkread.c sample does. I decided to start with this bit in
the expectation that getting these two lines of code working would be a
quick easy introduction to OpenSSL, certainly quicker and easier than
building the entire multithreaded asynchronous SSL server bit and hooking
that into the rest of the application.
What did I get wrong in the above chain of logic, and what should I have
done instead, and how should I have known to do something else instead?
(I do, by the way, see a couple of other people have had problems with
OpenSSL and the "_osfile(fh) & FOPEN" ASSERT but I couldn't find that anyone
had posted a solution.)
Tim Ward - Brett Ward Limited - 07801 703 600
www.brettward.co.uk
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org