Model key and trust store configurations as records and support PKCS#11 - #6395
Draft
beanuwave wants to merge 2 commits into
Draft
Model key and trust store configurations as records and support PKCS#11#6395beanuwave wants to merge 2 commits into
beanuwave wants to merge 2 commits into
Conversation
Introduces gradle/fips.gradle as the single place where FIPS mode is decided and applied to the build's test surface: which test classes exist in each mode and the JVM arguments test workers need to actually be in FIPS mode. Mode is driven by the OPENSEARCH_FIPS_MODE environment variable, surfaced to production code through the new FipsMode enum. BC FIPS artifacts move to compileOnly in both modes (they are provided by OpenSearch core), bctls-fips is added, and the securityadmin standalone bundles now ship the BC FIPS jars in deps/. Because java_test.security registers BouncyCastleFipsProvider in every test JVM -- including non-FIPS runs -- any suite that touches JCA now leaves a "BC FIPS Entropy Daemon" thread behind, which RandomizedRunner reports as a leak. BCFipsEntropyDaemonFilter covers it; the framework's BouncyCastleThreadFilter does not. It is applied to the suites that trip over it here, and reused by later FIPS work. No FIPS variant test classes exist yet, so this otherwise lands inert: the default build is unchanged and fips.gradle currently selects nothing. Signed-off-by: Iwan Igonin <iigonin@sternad.de> Co-authored-by: Benny Goerzig <benny.goerzig@sap.com> Co-authored-by: Karsten Schnitter <k.schnitter@sap.com> Co-authored-by: Kai Sternad <k.sternad@sternad.de>
Replaces the isPkcs11()-style branching in the SSL configuration layer with sealed pem/jdk/pkcs11 records for both key stores and trust stores, and moves PKCS#11 dispatch into those records. Store passwords are wrapped in a StorePassword type so they are redacted in toString() rather than leaking into logs. A PKCS#11 store lives on the token rather than on disk, so the path becomes optional throughout: KeyStoreUtils loads such stores with a null stream, and error messages name the token instead of a file. PemKeyReader learns the PKCS11 store type and validates that a PKCS#11 provider is actually registered. Trust store settings that a PKCS#11 configuration ignores now produce a warning instead of being silently dropped. Signed-off-by: Iwan Igonin <iigonin@sternad.de> Co-authored-by: Benny Goerzig <benny.goerzig@sap.com> Co-authored-by: Karsten Schnitter <k.schnitter@sap.com> Co-authored-by: Kai Sternad <k.sternad@sternad.de>
Contributor
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit af17522. ⛔ Hard block: Issues at High severity or above will block this PR from merging.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
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
Category: Enhancement, Refactoring
Independent of FIPS: this adds PKCS#11 (HSM) support for node TLS and replaces
ad-hoc
isPkcs11()-style branching with a type-driven model. Reviewable withoutany FIPS context.
Key changes
as
pem/jdk/pkcs11records, and PKCS#11 dispatch moves into the recordsthemselves rather than being re-decided at each call site.
StorePasswordwrapper. Store passwords are wrapped in a type whosetoString()redacts the value, so a password cannot reach a log through anaccidental interpolation.
optional throughout:
KeyStoreUtilsloads such stores with a null stream, anderror messages name the token instead of a non-existent file.
PemKeyReaderlearns the
PKCS11store type and validates that a PKCS#11 provider is actuallyregistered, rather than failing obscurely later.
non-exportable and BCJSSE cannot sign with it (
no encoding for key); SunJSSEdelegates the handshake signature to the key's own provider (SunPKCS11). So when
the keystore is PKCS#11,
SslConfigurationbuilds theSSLContextagainstSunJSSE (
SslContextBuilder.sslContextProvider(SunJSSE)).disregards produce a warning naming the exact setting, instead of being silently
dropped.
Reviewer notes
PKCS#11 capability on top.
PemSslCertificatesLoaderTestusesnextAlphanumeric(10)where the final branch usesPasswordValidator.FIPS_MIN_PASSWORD_LENGTH. That constant does not exist untilPR 5 — this is deliberate, please don't "fix" it here.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.