Skip to content

Commit

Permalink
Merge pull request #141 from cconlon/certgen
Browse files Browse the repository at this point in the history
X509v3 Certificate Generation Support (WolfSSLCertificate)
  • Loading branch information
JacobBarthelmeh committed Aug 22, 2023
2 parents f905670 + 61cd452 commit d4aeb31
Show file tree
Hide file tree
Showing 54 changed files with 4,491 additions and 496 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ IDE/WIN/DLL Debug
IDE/WIN/DLL Debug FIPS
IDE/WIN/DLL Release
IDE/WIN/DLL Release FIPS
examples/certs/generated

# RPM package files
rpm/spec
Expand Down
33 changes: 33 additions & 0 deletions IDE/WIN/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,37 @@ ant test-win32-release-fips
ant test-win64-debug-fips
ant test-win64-release-fips
```
# Running Examples

Windows batch scripts have been included to easily run some of the provided
examples from the Windows command line.

After the above steps have been followed to compile native wolfSSL and
wolfSSL JNI/JSSE, open a Command Prompt and navigate to the wolfSSL JNI/JSSE
directory root (ie: wolfssljni).

Compile the examples:

```
ant examples
```

Edit the Windows configuration batch script to set the appropriate paths
for native wolfSSL and wolfSSL JNI DLL locations. This can change between
build types (ex: normal wolfSSL, FIPS 140-2, etc):

**Edit examples\WindowsConfig.bat**

From the root wolfssljni directory, run the desired .bat file. For example,
to run the ProviderTest:

```
examples\provider\ProviderTest.bat
```

Or to run the X509v3 certificate generation example:

```
examples\X509v3CertificateGeneration.bat
```

2 changes: 2 additions & 0 deletions IDE/WIN/wolfssljni.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<ClCompile Include="..\..\native\com_wolfssl_WolfSSLCertManager.c" />
<ClCompile Include="..\..\native\com_wolfssl_WolfSSLContext.c" />
<ClCompile Include="..\..\native\com_wolfssl_WolfSSLSession.c" />
<ClCompile Include="..\..\native\com_wolfssl_WolfSSLX509Name.c" />
<ClCompile Include="..\..\native\com_wolfssl_WolfSSLX509StoreCtx.c" />
</ItemGroup>
<ItemGroup>
Expand All @@ -55,6 +56,7 @@
<ClInclude Include="..\..\native\com_wolfssl_WolfSSLCertManager.h" />
<ClInclude Include="..\..\native\com_wolfssl_WolfSSLContext.h" />
<ClInclude Include="..\..\native\com_wolfssl_WolfSSLSession.h" />
<ClInclude Include="..\..\native\com_wolfssl_WolfSSLX509Name.h" />
<ClInclude Include="..\..\native\com_wolfssl_WolfSSLX509StoreCtx.h" />
<ClInclude Include="..\..\native\com_wolfssl_WolfSSL_TLS_VERSION.h" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions IDE/WIN/wolfssljni.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<ClCompile Include="..\..\native\com_wolfssl_WolfSSLX509StoreCtx.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\native\com_wolfssl_WolfSSLX509Name.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\native\com_wolfssl_globals.h">
Expand Down Expand Up @@ -77,5 +80,8 @@
<ClInclude Include="..\..\native\com_wolfssl_WolfSSLX509StoreCtx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\native\com_wolfssl_WolfSSLX509Name.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ argument:
$ ./examples/server.sh --help
```

## X509v3 Certificate Generation Example

An example is included which will generate self-signed and CA-signed
X.509v3 certificates using the wolfSSL JNI library `WolfSSLCertificate`
class.

**X509v3CertificateGeneration.java** - Certificate generation example

This example is compiled when the `ant examples` target is executed, and can
be run afterwards with the provided bash script:

```
$ cd <wolfssljni_root>
$ ./examples/X509v3CertificateGeneration.sh
```

This will write out generated certificates to the following directory:

```
examples/certs/generated/
```

## Support

Please contact the wolfSSL support team at support@wolfssl.com with any
Expand Down
42 changes: 42 additions & 0 deletions examples/WindowsConfig.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

:: -----------------------------------------------------------------------------
:: Build Configuration
:: -----------------------------------------------------------------------------

:: Set below directories containing native wolfSSL DLL and wolfSSL JNI DLL
:: Default pathing expects wolfssl and wolfssljni dirs to be side by side
:: May uncomment / comment lines below that match your build. This file is
:: included by other example .bat files.

:: wolfSSL Normal non-FIPS (DLL Debug x64)
SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Debug\x64
SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Debug\x64

:: wolfSSL Normal non-FIPS (DLL Release x64)
:: SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Release\x64
:: SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Release\x64

:: wolfSSL Normal non-FIPS (DLL Debug Win32)
:: SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Debug\Win32
:: SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Debug\Win32

:: wolfSSL Normal non-FIPS (DLL Release Win32)
:: SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Release\Win32
:: SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Release\Win32

:: wolfSSL FIPS 140-2 #3389 Build (DLL Debug x64)
:: SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Debug\x64
:: SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Debug FIPS\x64

:: wolfSSL FIPS 140-2 #3389 Build (DLL Release x64)
:: SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Release\x64
:: SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Release FIPS\x64

:: wolfSSL FIPS 140-2 #3389 Build (DLL Debug Win32)
:: SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Debug\Win32
:: SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Debug FIPS\Win32

:: wolfSSL FIPS 140-2 #3389 Build (DLL Release Win32)
:: SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Release\Win32
:: SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Release FIPS\Win32

14 changes: 14 additions & 0 deletions examples/X509v3CertificateGeneration.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

cd %~dp0\build >NUL 2>NUL
SETLOCAL

:: Populate correct config for build
call ..\WindowsConfig.bat

:: Set PATH to include DLL for native wolfSSL and wolfSSL JNI (native library)
SET PATH="%WOLFSSLJNI_DLL_DIR%;%WOLFSSL_DLL_DIR%";%PATH%

java -cp ".;..\..\lib\wolfssl.jar;..\..\lib\wolfssl-jsse.jar" -Djava.library.path="%WOLFSSLJNI_DLL_DIR%;%WOLFSSL_DLL_DIR%" X509v3CertificateGeneration

ENDLOCAL
cd %~dp0\..
Loading

0 comments on commit d4aeb31

Please sign in to comment.