Build OpenSSL with Visual Studio 2008

These days building OpenSSL with Visual Studio 2008 has become really easy. I don’t like to edit .cnf files so i decided to patch the code a little so that the default configuration file becomes openssl.config:

string basePath = @"C:\src\openssl-0.9.8g";

string originalConfigfile = "openssl.cnf";
string updatedConfigfile = "openssl.config";
foreach (string filename in Directory.GetFiles(basePath, "*.*", SearchOption.AllDirectories))
{
 string contents = File.ReadAllText(filename);
 if (contents.Contains(originalConfigfile))
 {
  Console.WriteLine(filename);
  File.WriteAllText(filename, contents.Replace(originalConfigfile, updatedConfigfile));
 }
}

File.WriteAllText(basePath + @"\apps\" + updatedConfigfile, File.ReadAllText(basePath + @"\apps\" + originalConfigfile));

Open a Visual Studio 2008 Command prompt and add references to the Microsoft SDK as following:

SET PATH=%PATH%;C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
SET LIB=%LIB%;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
SET INCLUDE=%INCLUDE%;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include

Now we simply have to follow the tasks listed in INSTALL.W32:

perl Configure VC-WIN32 –prefix=c:/openssl
ms\do_masm
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak test
nmake -f ms\ntdll.mak install

Happy OpenSSL’ing!

  1. Newbie in OpenSSL :)
    Sorry for asking, could you tell me where to patch the code?

  2. Thanks for the information! I’ve got struggled with this stuff yesterday now I think I can resolve this problem thanks to you.

  3. thanks for the information. now I think I can resolve the problem I faced yesterday.

  4. it’s
    perl Configure VC-WIN32 –-prefix=c:/openssl

    NOT perl Configure VC-WIN32 –prefix=c:/openssl

    notice the missing – before -prefix

  5. Thanks for the info!
    However, now;
    perl Configure VC-WIN32 –prefix=c:/openssl
    ms\do_masm
    nmake -f ms\ntdll.mak
    nmake -f ms\ntdll.mak test
    nmake -f ms\ntdll.mak install
    all work fine (‘test’ says ~”all ok”),

    BUT: I still can’t build client.cpp (just copy/paste from http://www.boost.org/doc/libs/1_41_0/doc/html/boost_asio/example/ssl/client.cpp) in VC 2008 IDE – it keeps complaing about link-error:

    1>main.obj : error LNK2019: unresolved external symbol _SSLv23_server_method referenced in function “public: void __thiscall boost::asio::ssl::detail::openssl_context_service::create(struct ssl_ctx_st * &,enum boost::asio::ssl::context_base::method)” (?create@openssl_context_service@detail@ssl@asio@boost@@QAEXAAPAUssl_ctx_st@@W4method@context_base@345@@Z)
    etc.

    Any ideas?

  6. Hey there,
    You a have a typo in your instructions. It should read “ms\do_nasm”, not “ms\do_masm”.

    -John

  7. @John Cooper
    The choice between NASM and MASM is a choice between assemblers, MASM is Microsoft’s and since these are instructions to build OpenSsl with Visual Studio 2008 installed, using MASM makes more sense.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>