You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# wolfProvider Open Source Project Integration Guide
2
+
3
+
## Notes on Open Source Integration
2
4
3
5
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.
4
6
5
7
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.
6
8
7
-
## Tested Open Source Projects
9
+
###Tested Open Source Projects
8
10
9
11
The following Open Source Projects (OSPs) have been tested and verified to work with wolfProvider:
10
12
11
-
### Network and Web Technologies
13
+
####Network and Web Technologies
12
14
* cURL - Command line tool for transferring data with URLs
13
15
* gRPC - High-performance RPC framework
14
16
* libwebsockets - Lightweight C library for websockets
15
17
* Nginx - High-performance HTTP server and reverse proxy
16
18
* Qt5 Network - Qt networking module
17
19
18
-
### Security and Authentication
20
+
####Security and Authentication
19
21
* OpenSSH - Secure shell implementation
20
22
* libssh2 - SSH2 library
21
23
* libfido2 - FIDO2 library for WebAuthn
@@ -24,7 +26,7 @@ The following Open Source Projects (OSPs) have been tested and verified to work
24
26
* OpenVPN - VPN solution
25
27
* Stunnel - SSL wrapper for network services
26
28
27
-
### System and Network Tools
29
+
####System and Network Tools
28
30
* systemd - System and service manager
29
31
* tcpdump - Network packet analyzer
30
32
* rsync - File synchronization utility
@@ -33,12 +35,12 @@ The following Open Source Projects (OSPs) have been tested and verified to work
@@ -48,50 +50,286 @@ The following Open Source Projects (OSPs) have been tested and verified to work
48
50
* xmlsec - XML Security library
49
51
* sscep - SCEP client implementation
50
52
51
-
### Development and Testing
53
+
####Development and Testing
52
54
* Asan - Address Sanitizer testing
53
55
* Codespell - Spell checker for source code
54
56
* Multi-Compiler - Multi-compiler testing
55
57
56
-
### Remote Access and Display
58
+
####Remote Access and Display
57
59
* x11vnc - VNC server for X11
58
60
* python3-ntp - Python NTP library
59
61
60
-
### Other Utilities
62
+
####Other Utilities
61
63
* Socat - Multipurpose relay for bidirectional data transfer
62
64
* Simple - Simple test applications
63
65
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.
## Integrating an Open Source Project with wolfProvider
76
79
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
78
88
```
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:
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:
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
86
236
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.
88
238
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
91
240
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
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**
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
96
334
97
-
This comprehensive testing ensures that wolfProvider maintains compatibility with a wide range of open source projectsand 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