Compile OpenSSL from source
Download the source (openssl-1.0.1e.tar.gz) from
http://www.openssl.org/
When try to compile the source, please use the fresh/original source for each platform!
Linux gcc3 64-bit
Dynamic Library
cd /opt/mydir/openssl
gunzip -c openssl-1.0.1e.tar.gz | tar xvf -
mkdir linux-gcc3
cd openssl-1.0.1e
./config --prefix=/opt/mydir/openssl/linux-gcc3 enable-tlsext no-shared 2>&1 | tee conf_linux.log
make 2>&1 | tee make.log
make install
Static Library
cd /opt/mydir/openssl
gunzip -c openssl-1.0.1e.tar.gz | tar xvf -
mkdir linux-gcc3
cd openssl-1.0.1e
./config --prefix=/opt/mydir/openssl/linux-gcc3 enable-tlsext shared 2>&1 | tee conf_linux.log
make 2>&1 | tee make.log
make install
To use Linux 64bit to build binary (dynamic) for Linux x86, add this configuration into the ./config command
setarch i386 ./config --prefix=/opt/mydir/openssl/linux-gcc3 enable-tlsext no-shared -m32
Docker
We can also use the Docker Hub to build the OpenSSL on cloud.
- Create a github repo https://github.com/nguoianphu/docker-openssl.git
- Go to repo Setting > Webhooks and Services > Services. Adding the Docker services and check Active.
- Go to Docker repo and link the github repo https://registry.hub.docker.com/builds/add/
- Back to Github and create a file name Dockerfile. Example:
### Dockerfile for building latest OpenSSL
### I like CentOS
FROM centos:latest
MAINTAINER nguoianphu@gmail.com
### Some env variables
### I don't know how to get the latest version of OpenSSL, like openssl-latest.tar.gz
### So I have to put the version here
ENV OPENSSL_VERSION="1.0.2d"
RUN yum clean all \
&& yum -y update \
### Install tool for compiling
&& yum -y install gcc \
&& yum -y install make \
&& yum -y install wget \
&& yum -y install tar \
&& yum -y install perl \
&& yum clean all \
### BUILD OpenSSL
&& wget "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" -P /tmp/ \
&& tar -xvf /tmp/openssl-${OPENSSL_VERSION}.tar.gz \
&& rm -rf /tmp/openssl-${OPENSSL_VERSION}.tar.gz \
&& cd openssl-${OPENSSL_VERSION} \
&& ./Configure linux-x86_64 \
&& make \
&& make test \
&& make install \
&& cd .. \
&& rm -rf openssl-${OPENSSL_VERSION}
- Whenever we push a change into the githup repo, Docker Hub will trigger a new build base on Dockerfile. And, we don't even need any local machine to build OpenSSL. Just using the cloud!
Solaris Sparc 64-bit
Dynamic Library
cd /opt/mydir/openssl
gunzip -c openssl-1.0.1e.tar.gz | tar xvf -
mkdir solaris-2.x
cd openssl-1.0.1e
./Configure solaris64-sparcv9-cc --prefix=/opt/mydir/openssl/solaris-2.x enable-tlsext no-shared 2>&1 | tee conf_sol.log
make 2>&1 | tee make.log
make install
Static Library
cd /opt/mydir/openssl
gunzip -c openssl-1.0.1e.tar.gz | tar xvf -
mkdir solaris-2.x
cd openssl-1.0.1e
./Configure solaris64-sparcv9-cc --prefix=/opt/mydir/openssl/solaris-2.x enable-tlsext shared 2>&1 | tee conf_sol.log
make 2>&1 | tee make.log
make install
Solaris Sparc 32-bit Static
./config -m32 --prefix=/opt/mydir/openssl/solaris-2.x shared
Solaris x86
Dynamic Library and 64 bit
cd /opt/mydir/openssl
gunzip -c openssl-1.0.1e.tar.gz | tar xvf -
mkdir solaris-2.x
cd openssl-1.0.1e
./Configure solaris64-x86_64-cc --prefix=/opt/mydir/openssl/solaris-2.x enable-tlsext no-shared 2>&1 | tee conf_sol.log
make 2>&1 | tee make.log
make install
Static Library and 32 bit
cd /opt/mydir/openssl
gunzip -c openssl-1.0.1e.tar.gz | tar xvf -
mkdir solaris-2.x
cd openssl-1.0.1e
./Configure solaris-x86-cc --prefix=/opt/mydir/openssl/solaris-2.x enable-tlsext shared 2>&1 | tee conf_sol.log
make 2>&1 | tee make.log
make install
Windows
For setup only:
http://slproweb.com/products/Win32OpenSSL.html
Visual Studio
- Visual Studio 2010 (this will likely work with older versions as well)
- Need to install ActivePerl
- Create a directory to storage result, e.g. C:\openssl_x64 and C:\openssl_x86
Building the 64-bit libraries
- Open the Visual Studio x64 Win64 Command Prompt (2010) (in the Start menu)
- %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" amd64
- Change to OpenSSL source code, e.g. C:\openssl-1.0.1e
Enable Static Algorithms Engines (SHA, GOST, ...)
If you want to enable the static algorithms engines or build an DLL which includes the engines (SHA, GOST, ...)
perl Configure VC-WIN64A --prefix=C:\openssl_x64 no-asm no-shared enable-tlsext enable-static-engine
ms\do_win64a
If you dont' want to enable the algorithms engine (GOST), it will create some DLLs like gost.dll in the lib/engines/
perl Configure VC-WIN64A --prefix=C:\openssl_x64 no-asm no-shared enable-tlsext
ms\do_win64a
For Dynamic library
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak install
For Static library
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Building the 32-bit static libraries
Visual Studio 2010
- Open the Visual Studio x86 Command Prompt (2010) (in the Start menu)
- Change to OpenSSL source code, e.g. C:\openssl-1.0.1e
perl Configure VC-WIN32 --prefix=C:\openssl_x64
ms\do_nams
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Building the 64-bit static libraries with debug symbols
(These steps will embed the debug symbols directly into the .lib files)
- Open the Visual Studio x64 Win64 Command Prompt (2010) (in the Start menu)
- Change to OpenSSL source code, e.g. C:\openssl-1.0.1e
perl Configure debug-VC-WIN64A --prefix=C:\openssl_x86
ms\do_win64a
In a text editor (like Notepad), open ms\nt.mak and replace all occurrences of /Zi with /Z7 except on the line starting with ASM. There should be two replacements
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Building the 32-bit static libraries with debug symbols
(These steps will embed the debug symbols directly into the .lib files)
- Open the Visual Studio x86 Command Prompt (2010) (in the Start menu)
- Change to OpenSSL source code, e.g. C:\openssl-1.0.1e
perl Configure debug-VC-WIN32 --prefix=C:\openssl_x86
ms\do_ms
In a text editor (like Notepad), open ms\nt.mak and replace all occurrences of /Zi with /Z7 . There should be two replacements
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Visual C++ 6.0
Install the Microsoft Platform SDK for VC 6.0 to get its library and include directories (please google it :).
set INCLUDE=C:\buildtools\Microsoft SDK\include;%INCLUDE% set LIB=C:\buildtools\Microsoft SDK\lib;%LIB% perl Configure VC-WIN32 no-asm --prefix=C:\buildtools\openssl\openssl-1.0.1j\w2k msdo_ms nmake -f msntdll.mak nmake -f msntdll.mak install