As reported here,
calling functions from a DLL that take a FILE* can cause problems on
Windows. The OpenSSL API also includes alternative functions that
take a BIO* instead. I've attached two patches that replace these in
The first patch reads the key from the file into a string on the
libssh2 side and the passes this string to OpenSSL wrapped in a BIO*.
One issue that isn't taken care of yet is guarding for maximum file
size so if a large file is mistakenly given, it will allocate this
amount of memory naively. Does anyone know the maximum key file size?
The second patch (to be applied on top of the first) refactors the,
largely identical, key reading functions into a single function that
takes the OpenSSL function to use as a function-pointer argument. I
include this as a separate patch as I'm not sure which form is
I have only tested this with Visual Studio 2005 on Windows. Could
someone try this on other platforms please?
Comments very welcome.
Received on 2009-07-14