Improvement: Additional way to handle self-signed certificates if necessary#401
Merged
uhurusurfa merged 2 commits intoOpenAS2:masterfrom Nov 16, 2024
Merged
Conversation
Contributor
|
Thanks for the PR. I have had a quick scan through and the proposal looks better than the current implementation for self signed certificates. |
uhurusurfa
approved these changes
Nov 16, 2024
Contributor
uhurusurfa
left a comment
There was a problem hiding this comment.
👍 Thanks for the contribution. After going through all the changes necessary for the ultimate solution I decided to merge yours then make the changes myself for how this will be deployed into the nexrt release.
It will changed to use the PKCS12CertificateFactory module so that it is automaitcally monitored and reloaded and can be managed through an API.
| private static Set<String> cachedFingerprints = ConcurrentHashMap.newKeySet(); | ||
| private static KeyStore cachedCustomKeyStore = null; | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(AS2ReceiverHandler.class); |
Contributor
There was a problem hiding this comment.
Change "AS2ReceiverHandler" to "HTTPUtil"
Contributor
GreicodexJM
pushed a commit
to igwtech/OpenAs2App
that referenced
this pull request
Feb 26, 2026
…essary (OpenAS2#401) * custom self signed cert validation via environment variables based on custom trust store * optimized caching --------- Co-authored-by: Szabó Barnabás <szabo.barnabas@evonit.hu>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?