11# Building SoftHSM2 for Windows
22
3- This document describes process of building both 32-bit and 64-bit versions of [ SoftHSM2] ( https://www.opendnssec.org/softhsm/ ) on 64-bit Windows 8.1 machine.
3+ This document describes process of building both 32-bit and 64-bit versions of [ SoftHSM2] ( https://www.opendnssec.org/softhsm/ ) on 64-bit Windows 10 machine.
44
55## Required software
66
7- - [ Visual Studio] ( https://www.visualstudio.com/products/visual-studio-community-vs ) (2015 Community)
8- - [ GNU Privacy Guard for Windows] ( http://www.gpg4win.org/ ) (2.2.5 )
9- - [ 7-zip] ( http://www.7-zip.org/ ) (9.20 )
10- - [ Strawberry Perl] ( http://strawberryperl.com/ ) (5.22.0 .1)
11- - [ The Netwide Assembler] ( http://www.nasm.us/ ) (2.11.08 )
12- - [ Python] ( https://www.python.org/ ) (3.5.1 )
13- - [ Notepad++] ( https://notepad-plus-plus.org/ ) (6.8.1 )
14- - [ GitHub Desktop] ( https://desktop.github.com/ ) (3.0.4 .0)
15- - [ WiX Toolset] ( http://wixtoolset.org/ ) (3.10.0.1823 )
7+ - [ Visual Studio] ( https://www.visualstudio.com/vs/ ) (2015 Community)
8+ - [ GNU Privacy Guard for Windows] ( http://www.gpg4win.org/ ) (2.3.3 )
9+ - [ 7-zip] ( http://www.7-zip.org/ ) (16.04 )
10+ - [ Strawberry Perl] ( http://strawberryperl.com/ ) (5.24.1 .1)
11+ - [ The Netwide Assembler] ( http://www.nasm.us/ ) (2.12.02 )
12+ - [ Python] ( https://www.python.org/ ) (3.5.3 )
13+ - [ Notepad++] ( https://notepad-plus-plus.org/ ) (7.2.2 )
14+ - [ GitHub Desktop] ( https://desktop.github.com/ ) (3.3.3 .0)
15+ - [ WiX Toolset] ( http://wixtoolset.org/ ) (3.10.3.3007 )
1616
1717## Prepare working directories
1818
1919 mkdir C:\build\bin\
2020 mkdir C:\build\src\
2121
22- ## Build OpenSSL 1.0.2g static library
22+ ## Build OpenSSL 1.1.0d static library
2323
24- Download [ OpenSSL 1.0.2g ] ( http://openssl.org/source/openssl-1.0.2g .tar.gz ) with [ its signature] ( http://openssl.org/source/openssl-1.0.2g .tar.gz.asc ) into ` C:\build\src\ ` directory and verify signature of the downloaded archive:
24+ Download [ OpenSSL 1.1.0d ] ( http://openssl.org/source/openssl-1.1.0d .tar.gz ) with [ its signature] ( http://openssl.org/source/openssl-1.1.0d .tar.gz.asc ) into ` C:\build\src\ ` directory and verify signature of the downloaded archive:
2525
2626 cd C:\build\src\
2727 gpg --keyserver pgp.mit.edu --recv-keys 0E604491
28- gpg --verify openssl-1.0.2g .tar.gz.asc openssl-1.0.2g .tar.gz
28+ gpg --verify openssl-1.1.0d .tar.gz.asc openssl-1.1.0d .tar.gz
2929
3030### 32-bit
3131
32- Extract archive ` openssl-1.0.2g .tar.gz ` into ` C:\build\src\openssl-1.0.2g -x86 ` directory:
32+ Extract archive ` openssl-1.1.0d .tar.gz ` into ` C:\build\src\openssl-1.1.0d -x86 ` directory:
3333
3434 cd C:\build\src\
35- "C:\Program Files\7-Zip\7z" x openssl-1.0.2g .tar.gz
36- "C:\Program Files\7-Zip\7z" x openssl-1.0.2g .tar
37- rename openssl-1.0.2g openssl-1.0.2g -x86
38- del openssl-1.0.2g .tar
35+ "C:\Program Files\7-Zip\7z" x openssl-1.1.0d .tar.gz
36+ "C:\Program Files\7-Zip\7z" x openssl-1.1.0d .tar
37+ rename openssl-1.1.0d openssl-1.1.0d -x86
38+ del openssl-1.1.0d .tar
3939
40- In a ** new command line window** build OpenSSL and install it into ` C:\build\bin\openssl-1.0.2g -x86 ` directory:
40+ In a ** new command line window** build OpenSSL and install it into ` C:\build\bin\openssl-1.1.0d -x86 ` directory:
4141
42- cd C:\build\src\openssl-1.0.2g -x86
42+ cd C:\build\src\openssl-1.1.0d -x86
4343 set PATH=%PATH%;C:\nasm
4444 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
45- perl Configure VC-WIN32 --prefix=C:\build\bin\openssl-1.0.2g-x86 enable-static-engine
46- ms\do_nasm
47- nmake /f ms\nt.mak
48- nmake /f ms\nt.mak test
49- nmake /f ms\nt.mak install
50-
45+ perl Configure VC-WIN32 --prefix=C:\build\bin\openssl-1.1.0d-x86 --openssldir=C:\build\bin\openssl-1.1.0d-x86\ssl no-shared
46+ nmake
47+ nmake test
48+ nmake install
49+
5150## 64-bit
5251
53- Extract archive ` openssl-1.0.2g .tar.gz ` into ` C:\build\src\openssl-1.0.2g -x64 ` directory:
52+ Extract archive ` openssl-1.1.0d .tar.gz ` into ` C:\build\src\openssl-1.1.0d -x64 ` directory:
5453
5554 cd C:\build\src\
56- "C:\Program Files\7-Zip\7z" x openssl-1.0.2g .tar.gz
57- "C:\Program Files\7-Zip\7z" x openssl-1.0.2g .tar
58- rename openssl-1.0.2g openssl-1.0.2g -x64
59- del openssl-1.0.2g .tar
55+ "C:\Program Files\7-Zip\7z" x openssl-1.1.0d .tar.gz
56+ "C:\Program Files\7-Zip\7z" x openssl-1.1.0d .tar
57+ rename openssl-1.1.0d openssl-1.1.0d -x64
58+ del openssl-1.1.0d .tar
6059
61- In a ** new command line window** build OpenSSL and install it into ` C:\build\bin\openssl-1.0.2g -x64 ` directory:
60+ In a ** new command line window** build OpenSSL and install it into ` C:\build\bin\openssl-1.1.0d -x64 ` directory:
6261
63- cd C:\build\src\openssl-1.0.2g -x64
62+ cd C:\build\src\openssl-1.1.0d -x64
6463 set PATH=%PATH%;C:\nasm
6564 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
66- perl Configure VC-WIN64A --prefix=C:\build\bin\openssl-1.0.2g-x64 enable-static-engine
67- ms\do_win64a
68- nmake /f ms\nt.mak
69- nmake /f ms\nt.mak test
70- nmake /f ms\nt.mak install
65+ perl Configure VC-WIN64A --prefix=C:\build\bin\openssl-1.1.0d-x64 --openssldir=C:\build\bin\openssl-1.1.0d-x64\ssl no-shared
66+ nmake
67+ nmake test
68+ nmake install
7169
7270## Build CppUnit 1.13.2 unicode library
7371
@@ -111,41 +109,35 @@ Copy the results into `C:\build\bin\cppunit-1.13.2-x64` directory:
111109 mkdir C:\build\bin\cppunit-1.13.2-x64\include
112110 xcopy C:\build\src\cppunit-1.13.2-x64\include C:\build\bin\cppunit-1.13.2-x64\include /E
113111
114- ## Build SoftHSM 2.1 .0
112+ ## Build SoftHSM 2.2 .0
115113
116- Download [ SoftHSM 2.1 .0] ( https://dist.opendnssec.org/source/softhsm-2.1 .0.tar.gz ) with [ its signature] ( https://dist.opendnssec.org/source/softhsm-2.1 .0.tar.gz.sig ) into ` C:\build\src\ ` directory and verify signature of the downloaded archive:
114+ Download [ SoftHSM 2.2 .0] ( https://dist.opendnssec.org/source/softhsm-2.2 .0.tar.gz ) with [ its signature] ( https://dist.opendnssec.org/source/softhsm-2.2 .0.tar.gz.sig ) into ` C:\build\src\ ` directory and verify signature of the downloaded archive:
117115
118116 cd C:\build\src\
119117 gpg --keyserver pgp.mit.edu --recv-keys 4EE17CD2
120- gpg --verify softhsm-2.1 .0.tar.gz.sig softhsm-2.1 .0.tar.gz
118+ gpg --verify softhsm-2.2 .0.tar.gz.sig softhsm-2.2 .0.tar.gz
121119
122120### 32-bit
123121
124- Extract archive ` softhsm-2.1 .0.tar.gz ` into ` C:\build\src\softhsm-2.1 .0-x86 ` directory:
122+ Extract archive ` softhsm-2.2 .0.tar.gz ` into ` C:\build\src\softhsm-2.2 .0-x86 ` directory:
125123
126124 cd C:\build\src\
127- "C:\Program Files\7-Zip\7z" x softhsm-2.1.0.tar.gz
128- "C:\Program Files\7-Zip\7z" x softhsm-2.1.0.tar
129- rename softhsm-2.1.0 softhsm-2.1.0-x86
130- del softhsm-2.1.0.tar
131-
132- Download [ 6b2588ba62bbe75465ee55caa28cdccf2e6d7b5b.patch] ( SoftHSM/6b2588ba62bbe75465ee55caa28cdccf2e6d7b5b.patch ) and [ 19aa21262827d18d88adab73811e79f42c680743.patch] ( SoftHSM/19aa21262827d18d88adab73811e79f42c680743.patch ) into ` C:\build\src\ ` directory (see [ opendnssec/SoftHSMv2 #202 ] ( https://github.com/opendnssec/SoftHSMv2/pull/202 ) for more details). Apply these patches with the following commands executed in Git Shell (part of GitHub Desktop):
133-
134- cd C:\build\src\softhsm-2.1.0-x86\
135- patch -p1 -i C:\build\src\6b2588ba62bbe75465ee55caa28cdccf2e6d7b5b.patch
136- patch -p1 -i C:\build\src\19aa21262827d18d88adab73811e79f42c680743.patch
125+ "C:\Program Files\7-Zip\7z" x softhsm-2.2.0.tar.gz
126+ "C:\Program Files\7-Zip\7z" x softhsm-2.2.0.tar
127+ rename softhsm-2.2.0 softhsm-2.2.0-x86
128+ del softhsm-2.2.0.tar
137129
138130Configure build process in a ** new command line window** :
139131
140- cd C:\build\src\softhsm-2.1 .0-x86\win32\
132+ cd C:\build\src\softhsm-2.2 .0-x86\win32\
141133 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
142- python Configure.py disable-debug with-crypto-backend=openssl with-openssl=C:\build\bin\openssl-1.0.2g -x86\ with-cppunit=C:\build\bin\cppunit-1.13.2-x86\
134+ python Configure.py disable-debug disable-gost with-crypto-backend=openssl with-openssl=C:\build\bin\openssl-1.1.0d -x86\ with-cppunit=C:\build\bin\cppunit-1.13.2-x86\
143135
144- Open solution ` C:\build\src\softhsm-2.1 .0-x86\win32\softhsm2.sln ` in Visual Studio and rebuild the source with ` Release\Win32 ` solution configuration.
136+ Open solution ` C:\build\src\softhsm-2.2 .0-x86\win32\softhsm2.sln ` in Visual Studio and rebuild the source with ` Release\Win32 ` solution configuration.
145137
146138Verify the build by running the test programs:
147139
148- cd C:\build\src\softhsm-2.1 .0-x86\win32\Release\
140+ cd C:\build\src\softhsm-2.2 .0-x86\win32\Release\
149141 cryptotest.exe
150142 datamgrtest.exe
151143 handlemgrtest.exe
@@ -154,38 +146,32 @@ Verify the build by running the test programs:
154146 sessionmgrtest.exe
155147 slotmgrtest.exe
156148
157- Copy the results into ` C:\build\bin\softhsm-2.1 .0-x86 ` directory:
149+ Copy the results into ` C:\build\bin\softhsm-2.2 .0-x86 ` directory:
158150
159- mkdir C:\build\bin\softhsm-2.1 .0-x86
160- copy C:\build\src\softhsm-2.1 .0-x86\win32\Release\* C:\build\bin\softhsm-2.1 .0-x86\
151+ mkdir C:\build\bin\softhsm-2.2 .0-x86
152+ copy C:\build\src\softhsm-2.2 .0-x86\win32\Release\* C:\build\bin\softhsm-2.2 .0-x86\
161153
162154### 64-bit
163155
164- Extract archive ` softhsm-2.1 .0.tar.gz ` into ` C:\build\src\softhsm-2.1 .0-x64 ` directory:
156+ Extract archive ` softhsm-2.2 .0.tar.gz ` into ` C:\build\src\softhsm-2.2 .0-x64 ` directory:
165157
166158 cd C:\build\src\
167- "C:\Program Files\7-Zip\7z" x softhsm-2.1.0.tar.gz
168- "C:\Program Files\7-Zip\7z" x softhsm-2.1.0.tar
169- rename softhsm-2.1.0 softhsm-2.1.0-x64
170- del softhsm-2.1.0.tar
171-
172- Download [ 6b2588ba62bbe75465ee55caa28cdccf2e6d7b5b.patch] ( SoftHSM/6b2588ba62bbe75465ee55caa28cdccf2e6d7b5b.patch ) and [ 19aa21262827d18d88adab73811e79f42c680743.patch] ( SoftHSM/19aa21262827d18d88adab73811e79f42c680743.patch ) into ` C:\build\src\ ` directory (see [ opendnssec/SoftHSMv2 #202 ] ( https://github.com/opendnssec/SoftHSMv2/pull/202 ) for more details). Apply these patches with the following commands executed in Git Shell (part of GitHub Desktop):
173-
174- cd C:\build\src\softhsm-2.1.0-x64\
175- patch -p1 -i C:\build\src\6b2588ba62bbe75465ee55caa28cdccf2e6d7b5b.patch
176- patch -p1 -i C:\build\src\19aa21262827d18d88adab73811e79f42c680743.patch
159+ "C:\Program Files\7-Zip\7z" x softhsm-2.2.0.tar.gz
160+ "C:\Program Files\7-Zip\7z" x softhsm-2.2.0.tar
161+ rename softhsm-2.2.0 softhsm-2.2.0-x64
162+ del softhsm-2.2.0.tar
177163
178164Configure build process in a ** new command line window** :
179165
180- cd C:\build\src\softhsm-2.1 .0-x64\win32\
166+ cd C:\build\src\softhsm-2.2 .0-x64\win32\
181167 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
182- python Configure.py enable-64bit disable-debug with-crypto-backend=openssl with-openssl=C:\build\bin\openssl-1.0.2g -x64\ with-cppunit=C:\build\bin\cppunit-1.13.2-x64\
168+ python Configure.py enable-64bit disable-debug disable-gost with-crypto-backend=openssl with-openssl=C:\build\bin\openssl-1.1.0d -x64\ with-cppunit=C:\build\bin\cppunit-1.13.2-x64\
183169
184- Open solution ` C:\build\src\softhsm-2.1 .0-x64\win32\softhsm2.sln ` in Visual Studio and rebuild the source with ` Release\x64 ` solution configuration.
170+ Open solution ` C:\build\src\softhsm-2.2 .0-x64\win32\softhsm2.sln ` in Visual Studio and rebuild the source with ` Release\x64 ` solution configuration.
185171
186172Verify the build by running the test programs:
187173
188- cd C:\build\src\softhsm-2.1 .0-x64\win32\x64\Release\
174+ cd C:\build\src\softhsm-2.2 .0-x64\win32\x64\Release\
189175 cryptotest.exe
190176 datamgrtest.exe
191177 handlemgrtest.exe
@@ -194,10 +180,10 @@ Verify the build by running the test programs:
194180 sessionmgrtest.exe
195181 slotmgrtest.exe
196182
197- Copy the results into ` C:\build\bin\softhsm-2.1 .0-x64 ` directory:
183+ Copy the results into ` C:\build\bin\softhsm-2.2 .0-x64 ` directory:
198184
199- mkdir C:\build\bin\softhsm-2.1 .0-x64
200- copy C:\build\src\softhsm-2.1 .0-x64\win32\x64\Release\* C:\build\bin\softhsm-2.1 .0-x64\
185+ mkdir C:\build\bin\softhsm-2.2 .0-x64
186+ copy C:\build\src\softhsm-2.2 .0-x64\win32\x64\Release\* C:\build\bin\softhsm-2.2 .0-x64\
201187
202188## Create portable archive
203189
@@ -214,9 +200,9 @@ Create directory structure:
214200
215201Copy executables to ` C:\SoftHSM2\bin\ ` directory:
216202
217- copy C:\build\bin\softhsm-2.1 .0-x86\softhsm2-dump-file.exe C:\SoftHSM2\bin\
218- copy C:\build\bin\softhsm-2.1 .0-x86\softhsm2-keyconv.exe C:\SoftHSM2\bin\
219- copy C:\build\bin\softhsm-2.1 .0-x86\softhsm2-util.exe C:\SoftHSM2\bin\
203+ copy C:\build\bin\softhsm-2.2 .0-x86\softhsm2-dump-file.exe C:\SoftHSM2\bin\
204+ copy C:\build\bin\softhsm-2.2 .0-x86\softhsm2-keyconv.exe C:\SoftHSM2\bin\
205+ copy C:\build\bin\softhsm-2.2 .0-x86\softhsm2-util.exe C:\SoftHSM2\bin\
220206
221207Sign executables in ` C:\SoftHSM2\bin\ ` directory in a ** new command line window** :
222208
@@ -227,13 +213,13 @@ Sign executables in `C:\SoftHSM2\bin\` directory in a **new command line window*
227213
228214Copy configuration file to ` C:\SoftHSM2\etc\ ` directory:
229215
230- copy C:\build\bin\softhsm-2.1 .0-x86\softhsm2.conf C:\SoftHSM2\etc\
216+ copy C:\build\bin\softhsm-2.2 .0-x86\softhsm2.conf C:\SoftHSM2\etc\
231217 copy C:\SoftHSM2\etc\softhsm2.conf C:\SoftHSM2\etc\softhsm2.conf.sample
232218
233219Copy PKCS #11 libraries to ` C:\SoftHSM2\lib\ ` directory:
234220
235- copy C:\build\bin\softhsm-2.1 .0-x86\softhsm2.dll C:\SoftHSM2\lib\softhsm2.dll
236- copy C:\build\bin\softhsm-2.1 .0-x64\softhsm2.dll C:\SoftHSM2\lib\softhsm2-x64.dll
221+ copy C:\build\bin\softhsm-2.2 .0-x86\softhsm2.dll C:\SoftHSM2\lib\softhsm2.dll
222+ copy C:\build\bin\softhsm-2.2 .0-x64\softhsm2.dll C:\SoftHSM2\lib\softhsm2-x64.dll
237223
238224Sign PKCS #11 libraries in ` C:\SoftHSM2\lib\ ` directory in a ** new command line window** :
239225
@@ -243,15 +229,15 @@ Sign PKCS#11 libraries in `C:\SoftHSM2\lib\` directory in a **new command line w
243229
244230Copy licenses to ` C:\SoftHSM2\share\doc\ ` directory:
245231
246- copy C:\build\src\openssl-1.0.2g -x64\LICENSE C:\SoftHSM2\share\doc\openssl\LICENSE.txt
247- copy C:\build\src\softhsm-2.1 .0-x64\LICENSE C:\SoftHSM2\share\doc\softhsm2\LICENSE.txt
232+ copy C:\build\src\openssl-1.1.0d -x64\LICENSE C:\SoftHSM2\share\doc\openssl\LICENSE.txt
233+ copy C:\build\src\softhsm-2.2 .0-x64\LICENSE C:\SoftHSM2\share\doc\softhsm2\LICENSE.txt
248234
249235Copy manual pages to ` C:\SoftHSM2\share\man\ ` directory:
250236
251- copy C:\build\src\softhsm-2.1 .0-x64\src\lib\common\softhsm2.conf.5.in C:\SoftHSM2\share\man\man5\
252- copy C:\build\src\softhsm-2.1 .0-x64\src\bin\dump\softhsm2-dump-file.1 C:\SoftHSM2\share\man\man1\
253- copy C:\build\src\softhsm-2.1 .0-x64\src\bin\keyconv\softhsm2-keyconv.1 C:\SoftHSM2\share\man\man1\
254- copy C:\build\src\softhsm-2.1 .0-x64\src\bin\util\softhsm2-util.1 C:\SoftHSM2\share\man\man1\
237+ copy C:\build\src\softhsm-2.2 .0-x64\src\lib\common\softhsm2.conf.5.in C:\SoftHSM2\share\man\man5\
238+ copy C:\build\src\softhsm-2.2 .0-x64\src\bin\dump\softhsm2-dump-file.1 C:\SoftHSM2\share\man\man1\
239+ copy C:\build\src\softhsm-2.2 .0-x64\src\bin\keyconv\softhsm2-keyconv.1 C:\SoftHSM2\share\man\man1\
240+ copy C:\build\src\softhsm-2.2 .0-x64\src\bin\util\softhsm2-util.1 C:\SoftHSM2\share\man\man1\
255241
256242Move manual pages from ` C:\SoftHSM2\share\man\ ` to Linux box and convert them to text files:
257243
@@ -271,10 +257,10 @@ Convert EOL of `C:\SoftHSM2\etc\softhsm2.conf` and `C:\SoftHSM2\etc\softhsm2.con
271257
272258Create file [ ` C:\SoftHSM2\README.txt ` ] ( SoftHSM/misc/README.txt ) .
273259
274- Create archive ` C:\build\SoftHSM2-2.1 .0-portable.zip ` :
260+ Create archive ` C:\build\SoftHSM2-2.2 .0-portable.zip ` :
275261
276262 cd C:\build
277- "C:\Program Files\7-Zip\7z" a SoftHSM2-2.1 .0-portable.zip C:\SoftHSM2
263+ "C:\Program Files\7-Zip\7z" a SoftHSM2-2.2 .0-portable.zip C:\SoftHSM2
278264
279265## Create MSI installer
280266
@@ -287,9 +273,9 @@ Open solution `C:\build\src\SoftHSM2-for-Windows\WiX\SoftHSM2.sln` in Visual Stu
287273
288274Copy generated MSI installer to ` C:\build\ ` directory:
289275
290- copy C:\build\src\SoftHSM2-for-Windows\WiX\SoftHSM2\bin\Release\SoftHSM2.msi C:\build\SoftHSM2-2.1 .0.msi
276+ copy C:\build\src\SoftHSM2-for-Windows\WiX\SoftHSM2\bin\Release\SoftHSM2.msi C:\build\SoftHSM2-2.2 .0.msi
291277
292278Sign MSI installer in a ** new command line window** :
293279
294280 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
295- signtool.exe sign /sha1 84babdf3ba22669463db1ccfa7b1c917462bee4a /fd sha256 /tr http://time.certum.pl/ /td sha256 /d "SoftHSM2" /du "https://www.opendnssec.org/softhsm/" C:\build\SoftHSM2-2.1 .0.msi
281+ signtool.exe sign /sha1 84babdf3ba22669463db1ccfa7b1c917462bee4a /fd sha256 /tr http://time.certum.pl/ /td sha256 /d "SoftHSM2" /du "https://www.opendnssec.org/softhsm/" C:\build\SoftHSM2-2.2 .0.msi
0 commit comments