Repository navigation
Conversation
On a host running in FIPS mode, OpenSSL::PKCS12.create with its default arguments fails with "encrypt error" under OpenSSL 1.1.1 (Enterprise Linux 8), because the default bag encryption is RC2-40 and 3DES. The PKCS12 integrity MAC is keyed with the PKCS12 KDF, which the OpenSSL 3 FIPS provider does not implement either. The provider never sets these arguments, so java_ks cannot import a private key and certificate on such hosts. Ask for PBES2 with AES-256 explicitly, which is the OpenSSL 3 default and is read by keytool since Java 8u301 and 11.0.12, and skip the MAC when OpenSSL reports FIPS mode. The PKCS12 is a temporary file that keytool reads once, so the MAC adds nothing. Reproduced two ways. On AlmaLinux 8 with OPENSSL_FORCE_FIPS_MODE=1 the current call raises PKCS12Error "encrypt error" and the new call succeeds. On an AlmaLinux 9 host in FIPS mode with the FIPS build of the OpenVox agent (openvox-agent 8.31.1 redhatfips9, bundled OpenSSL 3.0.22, OpenSSL.fips_mode true) the module on main fails with "mac generation error", and with this change `puppet apply` imports the key into a JKS and into a PKCS12 keystore and the second run reports no changes. Red Hat's system OpenSSL 3 carries a PKCS12 KDF exception, so on AlmaLinux 9 with system Ruby both calls succeed. Signed-off-by: Michael Harp <mike@mikeharp.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The first version asked for PBES2 with AES-256 on every host. That is a no-op with OpenSSL 3, whose default it is, but on a non-FIPS host with OpenSSL 1.x it changed the format of a file that older keytools may not read (PBES2 support arrived in Java 8u301 and 11.0.12), and ensure => latest removes the existing alias before the import, so a failed import would also drop the working entry. The explicit algorithms and the missing MAC are now confined to FIPS mode, where the defaults cannot work at all. Signed-off-by: Michael Harp <mike@mikeharp.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
|
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.
Summary
On a host running in FIPS mode, importing a private key and certificate fails because
OpenSSL::PKCS12.createis called with its default arguments. Under OpenSSL 1.1.1 in FIPS mode (Enterprise Linux 8) the default bag encryption is RC2-40 and 3DES and the call raisesencrypt error; under an OpenSSL 3 whose FIPS provider has no PKCS12 KDF (for example the one bundled with the FIPS builds of the OpenVox agent) the integrity MAC cannot be derived and it raisesmac generation error. In both casesensure => latestfails withCould not set 'latest' on ensure.This change adds a
pkcs12_createhelper to the keytool provider. WhenOpenSSL.fips_modeis true it asks for PBES2 with AES-256 for both bags (the OpenSSL 3 default, readable bykeytoolsince Java 8u301 and 11.0.12) and skips the MAC; the PKCS12 is a temporary file thatkeytoolreads once, so the MAC adds nothing. Outside FIPS mode the call is unchanged, so hosts whose OpenSSL and Java already agree on a format keep it. Unit tests cover both branches; the README gains a FIPS note under Limitations.Additional Context
OPENSSL_FORCE_FIPS_MODE=1, system Ruby:OpenSSL::PKCS12.create(pass, name, key, cert, [])raisesPKCS12Error: encrypt error; with'AES-256-CBC', 'AES-256-CBC', nil, -1it succeeds andkeytool -importkeystoreaccepts the file.OpenSSL.fips_modetrue):java_ksfrommainfails withCould not set 'latest' on ensure: mac generation errorfor both the default (PKCS12) target keystore andstoretype => jks; with this branch both imports succeed and a second run reports no changes. Same result with openvox-agent 8.31.1 (OpenSSL 3.0.22).-importkeystore; keytool itself and the SHA-256 fingerprint comparison (Support for systems running in FIPS mode #160) are fine. The explicit algorithms and the missing MAC are confined to FIPS mode (second commit): with OpenSSL 3 they are the defaults anyway, and on a non-FIPS OpenSSL 1.x host forcing PBES2 would change a working file into one an older keytool may not read, which matters becauseensure => latestremoves the existing alias before the import.Related Issues (if any)
#160 is the only earlier FIPS change (MD5 to SHA-256 fingerprints, 2016). No open issue describes this failure.
Checklist
rake spec: 69 examples, 0 failures; rubocop clean)puppet applyon a FIPS-mode AlmaLinux 9 host with the OpenVox FIPS agent, PKCS12 and JKS target keystores, idempotent second run)Assisted by Claude.