Improvement: Additional way to handle self-signed certificates if necessary #401
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.
Description
This pull request introduces an enhancement to HTTPUtil.java in OpenAS2 to improve handling of self-signed certificates. Previously, the only option for trusting self-signed certificates was the TrustSelfSignedCN system property, which is not ideal in most cases.
Problem Statement
In our setup, we must accept self-signed certificates from trading partners when sending messages to them. Additionally, in a Kubernetes environment, relying on system properties is cumbersome and inflexible. Configuring trusted self-signed certificates with TrustSelfSignedCN would require a Docker image rebuild whenever certificates change, limiting the ability to update certificates independently of the application image.
Solution
This update allows OpenAS2 to dynamically load trusted self-signed certificates from a keystore file specified by environment variables:
With these environment variables set, HTTPUtil.java will bypass the need for TrustSelfSignedCN and use the specified keystore for SSL validation.
Changes Made
Benefits
Testing
This change has been tested in a Kubernetes environment to confirm that OpenAS2 dynamically reads the keystore and correctly validates self-signed certificates against it.
Summary
I just wanted to ask if there will be an update in the future that enhances the way self-signed certificates are handled in a more flexible manner, as the current TrustSelfSignedCN option was not sufficient for our needs.
In this pull request, I’ve introduced a solution that leverages environment variables to define the keystore path and password, making it possible to dynamically load trusted certificates without relying on system properties or requiring image rebuilds in Kubernetes environments.
Is this approach a good starting point, or is there a planned update that might handle self-signed certificates in an even more flexible way?