Wednesday, October 3, 2012

Building openSSL on windows

In order to build openSSL from the source code you will need to install a couple of third party free software. In this post I describe what I did on a virgin windows pc in order to build openSSL 1.0.1c.

First and foremost you will need perl. I prefer ActivePerl as I have worked with ActiveState’s perl IDE back in the IRC bot scripting days, but you can pick anything you like.

image

Moreover you will need Visual Studio C++.  The express edition is fine. I have been using the 2010 edition which is available for free at Microsoft.

image

Download the source code and extract it somewhere. Since I am building openSSL to use it in the webinos platfrom, I will be installing it at C:\OpenSSL-Win32. Moreover I don’t care about the assembly language files. So I configure the build environment giving the following command:

perl Configure VC-WIN32 no-asm --prefix=c:\OpenSSL-Win32

ms\do_ms.bat

Now it’s time to build things. Open a visual studio command prompt or in the existing prompt type:

call "%VS100COMNTOOLS%..\..\vc\vcvarsall.bat"

Note that this is for visual studio 2010 only (you will have to find the corresponding VSxxxCOMNTOOLS environment variable eg xxx=100 for 2010, xxx=90 for 2008 etc).

Now you can build openSSL by posting the following command:

nmake -f ms\ntdll.mak

A final step is to install it in the configured folder, which is done by posting the following command:

nmake -f ms\ntdll.mak install

Make sure you add the C:\OpenSSL-Win32\bin folder in your path environment variable and then enjoy your fresh build of openSSL.

PS: Now that you have build openSSL using visual studio 2010, you don’t need the VS2008 re-distributable which is required by the prebuild binaries that are available from the shining light production website. You need the VS2010 re-distributable though, which is already included in the webinos platform re-distributable.

3 comments:

Anonymous said...

Thanks, it was helpful.

Anonymous said...

To compile version 0.9.8c:

1)

This

perl Configure VC-WIN32 no-asm --prefix=c:\OpenSSL-Win32

needs to be

perl Configure VC-WIN32 no-asm --prefix=c:/OpenSSL-Win32

(with a forward slash)

http://openssl.6102.n7.nabble.com/Compilation-errors-in-openssl-0-9-8h-version-td17288.html

2) c:/openssl-0.9.8c/e_os.h needs this (about line 64)

#include
/* contains what we can justify to make visible
* to the outside; this file e_os.h is not part of the exported
* interface. */

#if defined(OPENSSL_SYS_WINDOWS)
#include
#endif

and this (around line 156)

#if defined(WINDOWS)
#define get_last_socket_error() WSAGetLastError()
#define clear_socket_error() WSASetLastError(0)
#define readsocket(s,b,n) recv((s),(b),(n),0)
#define writesocket(s,b,n) send((s),(b),(n),0)

#ifdef EADDRINUSE
#undef EADDRINUSE
#endif

Andreas Botsikas said...

Hi, and thanks for the info. As for the forward slash, it is not required, although technically you are right.
As for the 2nd edit, I do remember that we used to do some hacks to build open ssl but they are not required in the 1.x versions I have been building. I just built openssl-1.0.1e with visual studio 2012 without any issue, following the instructions from my post.