Skip to content

Commit b44cce6

Browse files
author
Test User
committed
Add General OSP Projecct Integration Guide for wolfProvider
1 parent 8b827f4 commit b44cce6

File tree

1 file changed

+269
-31
lines changed

1 file changed

+269
-31
lines changed

wolfProvider/src/chapter09.md

Lines changed: 269 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
# Notes on Open Source Integration
1+
# wolfProvider Open Source Project Integration Guide
2+
3+
## Notes on Open Source Integration
24

35
wolfProvider conforms to the general OpenSSL provider framework and architecture. As such, it can be leveraged from any OpenSSL-consuming application that correctly loads and initializes providers and wolfProvider through an OpenSSL configuration file or programmatically via API calls.
46

57
wolfSSL has tested wolfProvider with numerous open source projects through automated CI/CD workflows. This chapter contains notes and tips on wolfProvider integration with the tested projects.
68

7-
## Tested Open Source Projects
9+
### Tested Open Source Projects
810

911
The following Open Source Projects (OSPs) have been tested and verified to work with wolfProvider:
1012

11-
### Network and Web Technologies
13+
#### Network and Web Technologies
1214
* cURL - Command line tool for transferring data with URLs
1315
* gRPC - High-performance RPC framework
1416
* libwebsockets - Lightweight C library for websockets
1517
* Nginx - High-performance HTTP server and reverse proxy
1618
* Qt5 Network - Qt networking module
1719

18-
### Security and Authentication
20+
#### Security and Authentication
1921
* OpenSSH - Secure shell implementation
2022
* libssh2 - SSH2 library
2123
* libfido2 - FIDO2 library for WebAuthn
@@ -24,7 +26,7 @@ The following Open Source Projects (OSPs) have been tested and verified to work
2426
* OpenVPN - VPN solution
2527
* Stunnel - SSL wrapper for network services
2628

27-
### System and Network Tools
29+
#### System and Network Tools
2830
* systemd - System and service manager
2931
* tcpdump - Network packet analyzer
3032
* rsync - File synchronization utility
@@ -33,12 +35,12 @@ The following Open Source Projects (OSPs) have been tested and verified to work
3335
* IPMItool - IPMI management tool
3436
* PPP - Point-to-Point Protocol implementation
3537

36-
### Directory and Identity Services
38+
#### Directory and Identity Services
3739
* OpenLDAP - Lightweight Directory Access Protocol
3840
* SSSD - System Security Services Daemon
3941
* Net-SNMP - Network management protocol implementation
4042

41-
### Cryptography and PKI
43+
#### Cryptography and PKI
4244
* cjose - C library for JWT
4345
* libeac3 - Electronic Authentication Components
4446
* libhashkit2 - Consistent hashing library
@@ -48,50 +50,286 @@ The following Open Source Projects (OSPs) have been tested and verified to work
4850
* xmlsec - XML Security library
4951
* sscep - SCEP client implementation
5052

51-
### Development and Testing
53+
#### Development and Testing
5254
* Asan - Address Sanitizer testing
5355
* Codespell - Spell checker for source code
5456
* Multi-Compiler - Multi-compiler testing
5557

56-
### Remote Access and Display
58+
#### Remote Access and Display
5759
* x11vnc - VNC server for X11
5860
* python3-ntp - Python NTP library
5961

60-
### Other Utilities
62+
#### Other Utilities
6163
* Socat - Multipurpose relay for bidirectional data transfer
6264
* Simple - Simple test applications
6365

64-
## General Setup
65-
Most of these projects require similar setup steps:
66+
## Testing and Validation
67+
All of the above referenced open source project's are continuously tested in the wolfProvider CI/CD pipeline with:
68+
69+
* OpenSSL version `openssl-3.5.2`
70+
* wolfSSL version `v5.8.2-stable`
71+
* Force failure testing to ensure proper error handling
72+
* debian bookworm packaging testing
73+
* FIPS testing is also done through a Jenkins pipeline
74+
75+
This comprehensive testing ensures that wolfProvider consistently maintains compatibility with a wide range of open source projects and their various use cases.
76+
6677

67-
1. Clone from Github
68-
2. Build with Autotools
69-
3. Configure with OpenSSL
70-
4. Make and Install
71-
5. Use wolfProvider:
72-
```
73-
export OPENSSL_CONF=/path/to/provider.conf
74-
export OPENSSL_MODULES=/path/to/wolfprov-install/lib
75-
```
78+
## Integrating an Open Source Project with wolfProvider
7679

77-
After running make (or the equivalent build script) the configured version of OpenSSL can be checked by running `ldd /path/to/compiled/binary`. This will provide a list of which libraries are linked against. If the incorrect version is present then setting some combination of these four environment variables before rebuilding may help:
80+
This guide is designed to assist in integrating an Open Source Project (OSP) with wolfProvider.
81+
82+
### Building wolfProvider from Source
83+
84+
Build wolfProvider using the provided script:
85+
86+
```bash
87+
./scripts/build-wolfprovider.sh
7888
```
89+
90+
This script clones and builds a local installation of OpenSSL (into `openssl-source` and `openssl-install`), wolfSSL (into `wolfssl-source` and `wolfssl-install`), and also builds wolfProvider itself.
91+
92+
### Getting an OSP to use wolfProvider
93+
94+
#### Establish a Baseline
95+
96+
First, establish a baseline for test results. For this example, we will use cURL. Clone and build cURL with default options, then run `make test-ci` to ensure it works properly without wolfProvider:
97+
98+
```bash
99+
git clone https://github.com/curl/curl.git
100+
cd curl
101+
autoreconf -ivf
102+
./configure --with-openssl
103+
make
104+
make test-ci
105+
```
106+
107+
#### Check for Hard-Loaded Default Provider
108+
109+
Search the OSP source code for `provider_load`:
110+
111+
```bash
112+
grep -r "provider_load" .
113+
```
114+
115+
If the code hard-loads the default provider, it will need to be patched to use libwolfprov instead.
116+
117+
If the OSP code does not hard-load the default provider, then the provider is likely picked up from the OpenSSL configuration file being used. To override this behavior, use an OpenSSL configuration file that specifies wolfProvider. A sample configuration is provided at `wolfProvider/provider.conf`.
118+
119+
You will also need the appropriate `LD_LIBRARY_PATH` and `OPENSSL_MODULES` environment variables. The `OPENSSL_MODULES` variable is used as the path where provider libraries are searched.
120+
121+
To get a complete set of environment variables needed for testing you can run the following script:
122+
123+
```bash
124+
./scripts/test-sanity.sh
125+
```
126+
127+
This script dumps all environment variables used for testing. Copy the values for `LD_LIBRARY_PATH`, `OPENSSL_CONF`, and `OPENSSL_MODULES` from the output.
128+
129+
#### Run Tests with wolfProvider
130+
131+
Using the values copied from the `test-sanity.sh` output, export the environment variables and run the tests:
132+
133+
```bash
134+
export LD_LIBRARY_PATH=...
135+
export OPENSSL_CONF=...
136+
export OPENSSL_MODULES=...
137+
make test-ci
138+
```
139+
140+
### Verifying wolfProvider is Being Used
141+
142+
#### Using `WOLFPROV_FORCE_FAIL`
143+
144+
Even if the previous tests for the OSP run successfully, there is no guarantee that wolfProvider itself actually ran. If the default provider was being used instead, it would also pass with the same result. So we need to verify that wolfProvider is actually being used.
145+
146+
To ensure wolfProvider is actually running for the test, use the environment variable `WOLFPROV_FORCE_FAIL`. When set to `1`, all crypto calls to wolfProvider will fail. This allows us to verify exactly what is being used and if it is using wolfProvider. You can verify the behavior by running the following command:
147+
148+
```bash
149+
export WOLFPROV_FORCE_FAIL=1
150+
make test-ci
151+
```
152+
153+
If wolfProvider is being used, the tests should now fail. If they pass, then wolfProvider is not being used.
154+
155+
#### Using the `verify-install.sh` script
156+
157+
Another good test to run is the `scripts/verify-install.sh` script. This script will verify that the OpenSSL and wolfProvider libraries are installed correctly and that wolfProvider is being used. depending on the options you pass to the script, it will verify that the OpenSSL and wolfProvider libraries are installed correctly and that wolfProvider is being used.
158+
159+
```bash
160+
./scripts/verify-install.sh
161+
```
162+
163+
### Debugging wolfProvider
164+
165+
To debug wolfProvider, it must be rebuilt with debug options. This enables debug logging to stderr by default. Build with debug using the following commands:
166+
167+
```bash
168+
cd wolfProvider
169+
./scripts/build-wolfprovider.sh --distclean --debug
170+
```
171+
172+
wolfProvider is now built with debug symbols (as are local installs of OpenSSL and wolfSSL), and logs to stderr by default.
173+
174+
### wolfProvider "Gotchas"
175+
176+
There are a number of potential problems to be aware of when integrating an OSP with wolfProvider.
177+
178+
#### False Positives with WOLFPROV_FORCE_FAIL
179+
180+
A successful `WOLFPROV_FORCE_FAIL=1` test does not fully guarantee that the OSP under test is using wolfProvider. When you export environment variables, everything in the system uses those conditions.
181+
182+
For example, imagine a test framework where the OSP binary performs some work and outputs a PEM file. In a test script, you now call `openssl` to verify the contents of the PEM file, which fails because `openssl` now uses the always-failing provider when attempting the operation. In this case, the underlying OSP did not use wolfProvider, yet setting `WOLFPROV_FORCE_FAIL=1` gave the behavior you expected.
183+
184+
Always double-check that the underlying OSP is operating as you expect it to.
185+
186+
#### Inline Crypto and Algorithms Not Using OpenSSL
187+
188+
Some Open Source Projects implement cryptographic algorithms directly in their code rather than delegating to OpenSSL. These inline crypto implementations bypass OpenSSL entirely, which means they won't use wolfProvider even when it's properly configured.
189+
190+
OpenSSH is a prominent example of this behavior. By default, OpenSSH uses certain algorithms that are implemented directly in OpenSSH's code:
191+
192+
- `ed25519` - uses OpenSSH's inline crypto, not OpenSSL
193+
- `chacha20-poly1305` - also implemented in OpenSSH's own code
194+
- Many other OpenSSH-specific algorithms
195+
196+
When testing OpenSSH with `WOLFPROV_FORCE_FAIL=1`:
197+
198+
```bash
199+
export WOLFPROV_FORCE_FAIL=1
200+
ssh-keygen -t ed25519
201+
```
202+
203+
This test will likely succeed because the `ed25519` algorithm bypasses OpenSSL entirely and uses OpenSSH's inline implementation. Only operations that explicitly call OpenSSL's crypto APIs will fail with `WOLFPROV_FORCE_FAIL=1`.
204+
205+
Yet the command above could fail still in some cases. If Openssl is used in the background to parse the OpenSSL configuration file and other OpenSSL related operations. This could create a rare situation where `WOLFPROV_FORCE_FAIL=1` may cause OpenSSH tests to fail even though the primary cryptographic operations (like generating an ed25519 key or the chacha20-poly1305 cipher) are not using OpenSSL at all yet they still fail with WOLFPROV_FORCE_FAIL=1.
206+
207+
#### Complex Test Environments
208+
209+
Be on the lookout for complex test environments that override or explicitly set environment variables. Common issues include:
210+
211+
* Explicitly set `OPENSSL_CONF` variables
212+
* OSP binaries that run under systemd with custom environment handling
213+
* Test frameworks using VMs that need to be modified to inject new environment variables into them
214+
* Debug logs being swallowed by the test framework or sent directly to `/dev/null`
215+
216+
As a workaround for lost debug logs, consider modifying the logging to go directly to a local file.
217+
218+
#### Verifying Library Dependencies
219+
220+
After running make (or the equivalent build script), you can check which OpenSSL version is linked by running:
221+
222+
```bash
223+
ldd /path/to/compiled/binary
224+
```
225+
226+
This provides a list of which libraries are linked. If the incorrect version is present, set these environment variables before rebuilding:
227+
228+
```bash
79229
export LD_LIBRARY_PATH="/path/to/wolfssl/install/lib:/path/to/openssl/install/lib64"
80230
export PKG_CONFIG_PATH="/path/to/openssl/install/lib64/pkgconfig"
81231
export LDFLAGS="-L/path/to/openssl/install/lib64"
82232
export CPPFLAGS="-I/path/to/openssl/install/include"
83233
```
84234

85-
Further, wolfProvider gives some ability to determine if the library is actually using wolfProvider. Just do `export WOLFPROV_FORCE_FAIL=1` or `WOLFPROV_FORCE_FAIL=1 /command/to/run` and if the command ends up using wolfProvider crypto it will fail.
235+
### Alternative Approach: Replace Default
86236

87-
If the project being used is included in the list of tested open source project's then the testing scripts can be referenced. These can be found in the [wolfssl/wolfProvider](https://github.com/wolfSSL/wolfProvider) repository on GitHub under .github/workflows/.
237+
The traditional approach of configuring wolfProvider through environment variables or OpenSSL configuration files can be complex and error-prone, especially in production environments. The `--replace-default` option provides a robust alternative by modifying the OpenSSL source code itself to make wolfProvider the default cryptographic provider.
88238

89-
## Testing and Validation
90-
All of the above referenced open source project's are continuously tested in the wolfProvider CI/CD pipeline with:
239+
#### How Replace Default Works
91240

92-
* OpenSSL version 3.5.0
93-
* wolfSSL with both master and stable releases
94-
* Force failure testing to ensure proper error handling
95-
* FIPS testing is also done through a Jenkins pipeline
241+
When using `--replace-default`, the wolfProvider build script modifies OpenSSL's provider initialization code at compile-time. Instead of loading the standard OpenSSL default provider, the patched OpenSSL hard-loads wolfProvider as the default provider. This means:
242+
243+
* **No configuration files needed**: OpenSSL is compiled with wolfProvider as its built-in default
244+
* **No environment variables required**: `OPENSSL_CONF` and `OPENSSL_MODULES` are not needed
245+
* **Guaranteed provider usage**: Applications cannot accidentally use standard OpenSSL crypto since wolfProvider is the only provider
246+
* **Compile-time integration**: wolfProvider becomes part of OpenSSL rather than being loaded dynamically
247+
248+
The patch modifies OpenSSL's provider loading mechanism to statically link wolfProvider as the default provider during initialization, ensuring it's always used.
249+
250+
#### Building with Replace Default
251+
252+
To build wolfProvider with replace default enabled, use the build script:
253+
254+
```bash
255+
./scripts/build-wolfprovider.sh --replace-default
256+
```
257+
258+
This performs the following steps:
259+
1. **Downloads and patches OpenSSL**: Opens the OpenSSL source and applies a patch that hard-loads wolfProvider as the default provider
260+
2. **Builds patched OpenSSL**: Compiles OpenSSL with wolfProvider integrated
261+
3. **Builds wolfProvider**: Compiles the wolfProvider library against the patched OpenSSL
262+
4. **Installs components**: Installs both the patched OpenSSL and wolfProvider
263+
264+
For a complete rebuild from scratch:
265+
266+
```bash
267+
./scripts/build-wolfprovider.sh --distclean --replace-default
268+
```
269+
270+
#### Building your OSP with Replace Default
271+
272+
Here's a complete example demonstrating how to build and test your OSP using wolfProvider with the replace default approach for this example we used cURL again.
273+
274+
**Step 1: Build wolfProvider with Replace Default**
275+
276+
```bash
277+
cd wolfProvider
278+
./scripts/build-wolfprovider.sh --distclean --replace-default
279+
```
280+
281+
This creates a patched OpenSSL in `openssl-install/` that has wolfProvider as its default provider.
282+
283+
**Step 2: Build the OSP**
284+
285+
The next step would be to build the OSP. In the case of cURL, we can build it by running roughly the following commands:
286+
287+
```bash
288+
git clone https://github.com/curl/curl.git
289+
cd curl
290+
autoreconf -ivf
291+
./configure --with-openssl
292+
make
293+
make test-ci
294+
```
295+
296+
**Step 4: Verify wolfProvider is being used**
297+
298+
Since OpenSSL was patched to use wolfProvider as default, the built OSP will automatically use wolfProvider we can verify that replace default is in effect and correctly working by running the following command:
299+
300+
```bash
301+
./scripts/verify-install.sh --replace-default
302+
```
303+
304+
This should show that OpenSSL and wolfProvider are installed correctly with replace default in effect and it will look something like the following:
305+
306+
```bash
307+
Run $GITHUB_WORKSPACE/scripts/verify-install.sh --replace-default
308+
SUCCESS: openssl and wolfProvider installed correctly
309+
```
310+
311+
**Step 5: Force failure verification**
312+
313+
With replace default, you can still use `WOLFPROV_FORCE_FAIL` to verify wolfProvider is active:
314+
315+
```bash
316+
export WOLFPROV_FORCE_FAIL=1
317+
make test-ci
318+
```
319+
320+
#### When to Use Replace Default
321+
322+
This approach is recommended when:
323+
324+
* You have control over the OpenSSL installation and can rebuild OpenSSL
325+
* You need absolute certainty that wolfProvider is being used
326+
* You want to avoid environment variable and loading complexities
327+
* You're deploying to production environments where misconfiguration risk must be eliminated
328+
* You want system-wide consistency across all applications
329+
* You're building custom distributions or containers where you control the base OpenSSL
330+
331+
The replace default approach is used in wolfProvider's Debian packaging and CI/CD workflows currently. For working examples of this approach, see the GitHub Actions workflows in the [wolfProvider repository](https://github.com/wolfSSL/wolfProvider/tree/master/.github/workflows).
332+
333+
### Reference Implementation
96334

97-
This comprehensive testing ensures that wolfProvider maintains compatibility with a wide range of open source projects and their various use cases.
335+
If the OSP you are integrating is included in the list of tested open source projects, we have already implented and tested your project!You can check out exactly how we did it by looking at the GitHub Actions workflows in the [wolfSSL/wolfProvider](https://github.com/wolfSSL/wolfProvider) repository on GitHub under `.github/workflows/`. For example, the cURL integration workflow is available at [here](https://github.com/wolfSSL/wolfProvider/blob/master/.github/workflows/curl.yml)

0 commit comments

Comments
 (0)