Skip to content

(MODULES-12083) Load facts on FIPS JRuby without openssl - #256

Open
span786 wants to merge 2 commits into
mainfrom
MODULES-12083/main/fips-openssl-guard
Open

span786 wants to merge 2 commits into
mainfrom
MODULES-12083/main/fips-openssl-guard

Conversation

@span786

@span786 span786 commented Nov 12, 2026

Copy link
Copy Markdown

Summary

On a FIPS PE primary, Puppet Server's JRuby cannot load openssl. The bare require 'openssl' at lib/shared/pe_status_check.rb:4 raises NameError, the file aborts, and the pe_status_check fact is never defined server-side:

ERROR [puppetserver] Facter Unable to add resolve nil for fact 'pe_status_check': cannot load (ext) (org.jruby.ext.openssl.OpenSSL)
  .../jopenssl/load.rb:26
  .../openssl.rb:3
  /opt/puppetlabs/puppet/cache/lib/shared/pe_status_check.rb:4

This was reported by a customer on PE 2025.11.3 (JRuby 9.4.12.1). It's not specific to JRuby 10. The full root-cause analysis is in PE-45614.

Changes

  • Replace the bare require with PEStatusCheck.load_openssl, which rescues LoadError/NameError. The result is exposed as PEStatusCheck.openssl_available?.
    • Availability comes from our own rescue, not from defined?(OpenSSL). On FIPS JRuby, Puppet's openssl_loader installs stub constants under that name, so the constant exists even though the crypto doesn't.
  • http_get returns false early when openssl is unavailable.
  • When openssl is unavailable, the cert/CRL expiry chunks S0005, S0015, S0023 and S0025 (in pe_status_check) and AS001 and AS004 (in agent_status_check) are skipped.
  • MRI behaviour is unchanged. The agent-side fact collection that feeds PuppetDB and the console still runs every check.

Note for reviewers: when the fact resolves server-side on FIPS, chunks that call http_get (S0004, S0016, etc.) report false, which is the same as when the HTTP call fails. This follows the proposal in PE-45614. We could skip those chunks instead if that's preferred.

Testing

  • New spec/unit/pe_status_check_openssl_spec.rb:
    • the load guard on NameError and LoadError;
    • http_get not building an SSL client;
    • each of the 6 chunks being skipped. OpenSSL constructors are stubbed to raise, so any unguarded use fails the test.
  • Without the lib/facter guards, the new specs fail (6 failures). With them, all 27 unit examples pass. rubocop, syntax and lint are clean.
  • Still to do before this leaves draft: validate on a RHEL 8 FIPS PE primary and confirm the error is gone from puppetserver.log.

Follow-up

  • Release the module, then bump the pin in pe-modules-vanagon/configs/components/pe_status_check.json (PE-45614).
  • Backport to the refs pinned by 2025.11.x and 2025.12.x.

Jira: MODULES-12083, PE-45614

🤖 Generated with Claude Code

Puppet Server's JRuby on a FIPS host cannot load openssl: no FIPS
BouncyCastle jar provides the lightweight-API classes jruby-openssl needs,
so the bare `require 'openssl'` in lib/shared/pe_status_check.rb raised
NameError, aborting the file and leaving the pe_status_check fact undefined
server-side ("cannot load (ext) (org.jruby.ext.openssl.OpenSSL)").

Make the require non-fatal and record the result in
PEStatusCheck.openssl_available?. Availability is tracked by our own
rescue rather than defined?(OpenSSL), because Puppet's openssl_loader
installs stub constants under that name on FIPS JRuby.

When openssl is unavailable, http_get returns false without building an
SSL client, and the cert/CRL expiry chunks (S0005, S0015, S0023, S0025,
AS001, AS004) are skipped. Behaviour on MRI is unchanged.

Root cause analysis: PE-45614.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread lib/shared/pe_status_check.rb Outdated
false
end

OPENSSL_AVAILABLE = load_openssl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what's breaking acceptance. The shared file gets loaded twice, once from the modulepath and once from the pluginsync cache, so the constant is assigned twice and Ruby warns:

warning: already initialized constant PEStatusCheck::OPENSSL_AVAILABLE

That warning kills the idempotent apply in the exclude list test, and users would see it on agent runs too. Something like this should fix it:

OPENSSL_AVAILABLE = load_openssl unless const_defined?(:OPENSSL_AVAILABLE)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. I reproduced it locally: loading the shared file from two paths emits warning: already initialized constant PEStatusCheck::OPENSSL_AVAILABLE. The old file defined no constants, which is why this never came up before. It also explains the acceptance results: the 4 failures already present on #254 plus 4 new ones here.

Fixed in 68413fa as you suggested: OPENSSL_AVAILABLE = load_openssl unless const_defined?(:OPENSSL_AVAILABLE, false), with a comment explaining the double load. I passed false so the check doesn't pick up a constant of the same name from an ancestor or the top level. I also added a unit spec that loads the shared file a second time and asserts nothing is written to stderr. It fails without the guard and passes with it.

chunk(:AS001) do
# Is the hostcert expiring within 90 days
#
next unless PEStatusCheck.openssl_available?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file doesn't require the shared lib itself and only works because pe_status_check_role.rb loads it first. Not new, but worth adding require_relative '../shared/pe_status_check' now that we're calling into it more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Done in 68413fa. agent_status_check.rb now does require_relative '../shared/pe_status_check' straight after require 'puppet', the same way pe_status_check.rb does. I moved the confine { PEStatusCheck.enabled? } below it so the module is defined before that confine runs, rather than relying on load order.

…agent fact

The shared file can be loaded twice in one process (from the modulepath
and from the pluginsync cache), so re-assigning OPENSSL_AVAILABLE emitted
"already initialized constant PEStatusCheck::OPENSSL_AVAILABLE" on agent
runs, which broke the idempotent apply in acceptance. Only assign it when
it is not already defined, and add a spec that loads the file again.

agent_status_check now requires the shared lib itself instead of relying
on another fact having loaded it first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@span786

span786 commented Nov 20, 2026

Copy link
Copy Markdown
Author

Update on CI after 68413fa: the double-load constant warning is gone. All 8 remaining acceptance failures are S0007/S0008 (less than 20% disk free on the Litmus VM, plus fallocate failing in the "filesystem usage exceeds 80%" examples), the same signature that failed 4 jobs on #254 before it merged. So I believe they're environmental and unrelated to this change. Next I'll validate on a RHEL 8 FIPS PE primary, then mark the PR ready for review.

@span786
span786 marked this pull request as ready for review November 26, 2026 05:58
@span786
span786 requested review from a team as code owners November 26, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants