Skip to content

[9.1](backport #5088) [FIPS] Test that ES client will not connect to ES with invalid TLS certificate#5142

Merged
ycombinator merged 1 commit into9.1from
mergify/bp/9.1/pr-5088
Jul 10, 2025
Merged

[9.1](backport #5088) [FIPS] Test that ES client will not connect to ES with invalid TLS certificate#5142
ycombinator merged 1 commit into9.1from
mergify/bp/9.1/pr-5088

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Jul 10, 2025

What is the problem this PR solves?

This PR ensures that any connections made by a FIPS-capable Fleet Server to Elasticsearch will only succeed if Elasticsearch is also FIPS-capable.

How does this PR solve the problem?

This PR adds a new test, TestConnectionTLS, that fakes an Elasticsearch HTTPS server that returns a TLS certificate that's been created with a key length of < 2048 bits, making it invalid for FIPS-compliant use.

If running in FIPS mode, the test asserts that Fleet Server's connection to Elasticsearch will fail with a TLS error.
If not running in FIPS mode, the test asserts that Fleet Server's connection to Elasticsearch will succeed.

How to test this PR locally

In a non-FIPS environment:

$ go test ./internal/pkg/es/... -v -test.run TestConnectionTLS -test.count 1
=== RUN   TestConnectionTLS
--- PASS: TestConnectionTLS (0.00s)
PASS
ok  	github.com/elastic/fleet-server/v7/internal/pkg/es	0.389s

In a FIPS environment, i.e. with the Microsoft Go fork installed and with the OpenSSL FIPS provider installed:

$ GOEXPERIMENT=systemcrypto go test --tags=requirefips ./internal/pkg/es/... -v -test.run TestConnectionTLS -test.count 1
=== RUN   TestConnectionTLS
2025/07/03 15:46:02 http: TLS handshake error from 127.0.0.1:52214: tls: failed to sign handshake: EVP_PKEY_sign_init failed
openssl error(s):
error:1C800069:Provider routines::invalid key length
	providers/common/securitycheck.c:65
--- PASS: TestConnectionTLS (0.00s)
PASS
ok  	github.com/elastic/fleet-server/v7/internal/pkg/es	0.022s

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

Related issues


This is an automatic backport of pull request #5088 done by [Mergify](https://mergify.com).

…rtificate (#5088)

* Adding unit test for connecting to FIPS-incapable ES

* Make linter happy

* Reordering imports

* Run FIPS unit tests on FIPS VM

* Install Microsoft Go if FIPS=true

* Debugging

* Use fleet server FIPS VM image

* Debugging: extracting microsoft/go outside of fleet-server folder

* Explicitly specify Go distribution for tests

* Use temporary folder for microsoft/go SDK

* Don't pass GOEXPERIMENT=systemcrypto when running tests with Go stdlib

* Remove debugging statements

* Reduce VM size

(cherry picked from commit c0ae099)
@mergify mergify bot added the backport label Jul 10, 2025
@mergify mergify bot requested a review from a team as a code owner July 10, 2025 21:23
@mergify mergify bot requested a review from kaanyalti July 10, 2025 21:23
@mergify mergify bot requested a review from michel-laterman July 10, 2025 21:23
@mergify mergify bot added the backport label Jul 10, 2025
@prodsecmachine
Copy link

prodsecmachine commented Jul 10, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions github-actions bot added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Jul 10, 2025
@elastic-sonarqube
Copy link

@ycombinator ycombinator merged commit 2501f45 into 9.1 Jul 10, 2025
10 checks passed
@ycombinator ycombinator deleted the mergify/bp/9.1/pr-5088 branch July 10, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants