-
Notifications
You must be signed in to change notification settings - Fork 28
When installing in standalone mode, don't modify system config #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
padelsbach
wants to merge
1
commit into
wolfSSL:master
Choose a base branch
from
padelsbach:wp-debian-standalone-no-install
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,6 @@ | ||
| #!/bin/sh | ||
| set -e | ||
|
|
||
| # Define the include line to add to the openssl.cnf file | ||
| INCLUDE_LINE=".include /etc/ssl/openssl.cnf.d/wolfprovider.conf" | ||
|
|
||
| # Search for the openssl.cnf file in /usr, /lib and /etc | ||
| CONF_FILES=$(find /usr /lib /etc -name openssl.cnf 2>/dev/null) | ||
|
|
||
| # Check if we are in replace-default mode by reading the openssl version | ||
| REPLACE_DEFAULT=0 | ||
| if command -v openssl >/dev/null 2>&1; then | ||
|
|
@@ -16,29 +10,97 @@ if command -v openssl >/dev/null 2>&1; then | |
| fi | ||
| fi | ||
|
|
||
| if [ $REPLACE_DEFAULT -eq 1 ]; then | ||
| # Remove INCLUDE_LINE from each CONF_FILE | ||
| # Replace default mode should automatically find wolfProvider. | ||
| # Using the config file or OPENSSL_CONF will cause: | ||
| # 1. the provider name to be 'libwolfprov' instead of 'default' | ||
| # 2. the provider init call to happen twice | ||
| # Neither of these is harmful, but it's not ideal. | ||
| for CONF_FILE in $CONF_FILES; do | ||
| # Remove any line containing both ".include" and "wolfprovider.conf" | ||
| sed -i '/\.include/ { /wolfprovider\.conf/ d; }' "$CONF_FILE" | ||
| printf "Removed wolfprovider include line(s) from %s\n" "$CONF_FILE" | ||
| done | ||
| else | ||
| # For each CONF_FILE, apply the include line to the openssl.cnf file, if not already applied | ||
| for CONF_FILE in $CONF_FILES; do | ||
| if grep -qF "$INCLUDE_LINE" "$CONF_FILE"; then | ||
| echo "Include line already exists in $CONF_FILE" | ||
| else | ||
| echo "Adding include for wolfprovider to $CONF_FILE..." | ||
| echo "$INCLUDE_LINE" >> "$CONF_FILE" | ||
| fi | ||
| done | ||
| if [ "$1" = "configure" ]; then | ||
| if [ $REPLACE_DEFAULT -eq 1 ]; then | ||
| cat <<'EOF' | ||
| ============================================================ | ||
| wolfProvider Installation Notes | ||
| ============================================================ | ||
|
|
||
| wolfProvider is installed in replace-default mode with a | ||
| patched version of OpenSSL that uses wolfProvider as the | ||
| crypto backend. wolfProvider will appear as the 'default' | ||
| provider. | ||
|
|
||
| No other conf file modifications or environment variables | ||
| are required. | ||
|
|
||
| To verify installation, run: | ||
| openssl version | ||
| openssl list -providers | ||
|
|
||
| wolfProvider configuration file installed at: | ||
| /etc/ssl/openssl.cnf.d/wolfprovider.conf | ||
|
|
||
| ============================================================ | ||
| EOF | ||
| else | ||
| cat <<'EOF' | ||
| ============================================================ | ||
| wolfProvider Installation Notes | ||
| ============================================================ | ||
|
|
||
| To use wolfProvider with OpenSSL, choose ONE of the options | ||
| below depending on your use case. | ||
|
|
||
| 1) System-wide enable: | ||
|
|
||
| Add the following line to your /etc/ssl/openssl.cnf: | ||
|
|
||
| .include /etc/ssl/openssl.cnf.d/wolfprovider.conf | ||
|
|
||
| This makes wolfProvider available to all applications | ||
| that utilize the standard system openssl configuration. | ||
|
|
||
|
|
||
| 2) Per-command enable (no system-wide changes) | ||
|
|
||
| Set OPENSSL_CONF when running a program: | ||
|
|
||
| OPENSSL_CONF=/etc/ssl/openssl.cnf.d/wolfprovider.conf \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will work for more than just openssl commands, most applications with standard environment handling will be able to use this method, not just the openssl binary. |
||
| <command> | ||
|
|
||
| This enables use of wolfProvider whenever the | ||
| environment variable is set for the current shell. | ||
|
|
||
|
|
||
| 3) Application-level integration (for developers) | ||
|
|
||
| In your application, you can create a dedicated OpenSSL | ||
| library context and explicitly load wolfProvider, e.g.: | ||
|
|
||
| OSSL_LIB_CTX *wpLibCtx = OSSL_LIB_CTX_new(); | ||
| OSSL_PROVIDER *wpProv = OSSL_PROVIDER_load(wpLibCtx, "wolfprovider"); | ||
| /* Use wpLibCtx with EVP, etc. */ | ||
| EVP_function(wpLibCtx, ...); | ||
| OSSL_PROVIDER_unload(wpProv); | ||
| OSSL_LIB_CTX_free(wpLibCtx); | ||
|
|
||
| This keeps wolfProvider usage scoped to specific code paths | ||
| without requiring any system-wide configuration changes. | ||
|
|
||
| To verify installation and configuration, run: | ||
| openssl version | ||
| openssl list -providers | ||
|
|
||
| wolfProvider configuration file installed at: | ||
| /etc/ssl/openssl.cnf.d/wolfprovider.conf | ||
|
|
||
| ============================================================ | ||
| EOF | ||
| fi | ||
| fi | ||
|
|
||
| # Search for the openssl.cnf file in /usr, /lib and /etc | ||
| CONF_FILES=$(find /usr /lib /etc -name openssl.cnf 2>/dev/null) | ||
|
|
||
| # Warn user on install or removal if our config file is already included. | ||
| for CONF_FILE in $CONF_FILES; do | ||
| if grep '.include' "$CONF_FILE" | grep -q "wolfprovider.conf"; then | ||
| echo "WARNING: wolfprovider.conf is already included in $CONF_FILE" | ||
| fi | ||
| done | ||
|
|
||
|
|
||
| #DEBHELPER# | ||
| exit 0 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this language needs to be changed a bit. Something closer to "available to all applications that execute with the standard system openssl configuration". Many applications such as anything executing from systemd will ignore the global conf entirely, we should make this clear imo.