Skip to content

fix: validate a user-supplied CA for the transport layer of Elasticsearch#8953

Merged
pkoutsovasilis merged 3 commits intoelastic:mainfrom
pkoutsovasilis:fix/validate_custom_ca
Jan 7, 2026
Merged

fix: validate a user-supplied CA for the transport layer of Elasticsearch#8953
pkoutsovasilis merged 3 commits intoelastic:mainfrom
pkoutsovasilis:fix/validate_custom_ca

Conversation

@pkoutsovasilis
Copy link
Contributor

@pkoutsovasilis pkoutsovasilis commented Dec 11, 2025

What does this PR do?

This pull request ensures that when a user supplies a custom CA for the Elasticsearch transport layer, the operator validates the CA’s expiration and prevents the system from endlessly attempting to renew certificates with an expired CA. Instead, it emits a clear error or event when an expired CA is detected.

Why is it important?

Currently, if a user-supplied CA has expired, the ECK operator continually attempts (and fails) to renew certificates, resulting in silent failures and unclear operator behavior. This validation allows users to receive explicit feedback and error events when their CA is no longer valid, improving transparency and usability.

Implementation details

  • Adds validation logic for user-supplied CA certificates for the transport layer.
  • The operator checks that the supplied CA is present, well-formed, and suitable for use with Elasticsearch transport layer encryption.
  • If validation fails, the operator will report relevant errors in status, preventing misconfigured CAs from being used for cluster transport security.
  • Unit tests have been added or updated to cover cases for valid and invalid CA submission.

Related issues

@pkoutsovasilis pkoutsovasilis self-assigned this Dec 11, 2025
@pkoutsovasilis pkoutsovasilis added >bug Something isn't working v3.3.0 labels Dec 11, 2025
@prodsecmachine
Copy link
Collaborator

prodsecmachine commented Dec 11, 2025

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

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds validation for user-supplied CA certificates in the Elasticsearch transport layer to ensure certificates are valid before use.

Key changes:

  • Introduces a ValidateCustomCA function that checks certificate validity periods and key pair matching
  • Integrates validation into the CA reconciliation flow with user-facing error events
  • Adds comprehensive test coverage for different validation failure scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/controller/elasticsearch/certificates/transport/ca.go Adds validation call for custom CA certificates with error event reporting
pkg/controller/common/certificates/ca_secret.go Implements ValidateCustomCA function with time-bound and key-matching checks
pkg/controller/common/certificates/ca_secret_test.go Adds test cases for valid, expired, not-yet-valid, and key-mismatched CAs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pkoutsovasilis
Copy link
Contributor Author

buildkite test this -f p=gke,E2E_TAGS=es,t=TestCustom*

@pkoutsovasilis pkoutsovasilis marked this pull request as ready for review December 11, 2025 13:04
Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

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

LGTM. But it creates a behavioural gap between the transport and HTTP layer. We do not have a similar check for custom HTTP certificates. Example:

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: quickstart
spec:
  version: 9.2.0
  http:
    tls:
      certificate:
        secretName: custom-cert

Could you create a follow-up issue (and/or PR)?

@pkoutsovasilis
Copy link
Contributor Author

Nice catch @pebrc ! I've created a follow-up issue here: #8990

I'll work on a PR to add the same validation for the HTTP layer to ensure we have consistent behavior across both layers.

Quick question: since the 3.3.0 release is upon us, should I go ahead and merge this PR now, or should I wait?

@pebrc
Copy link
Collaborator

pebrc commented Jan 7, 2026

Quick question: since the 3.3.0 release is upon us, should I go ahead and merge this PR now, or should I wait?

3.3. has been branched off so you can merge this anytime now but it won't be included in the release. We can discuss whether we consider this bug significant enough to warrant a back port to the release branch. I am not sure it is.

@pkoutsovasilis pkoutsovasilis merged commit 504f977 into elastic:main Jan 7, 2026
10 checks passed
@pkoutsovasilis
Copy link
Contributor Author

3.3. has been branched off so you can merge this anytime now but it won't be included in the release. We can discuss whether we consider this bug significant enough to warrant a back port to the release branch. I am not sure it is.

I totally agree with your assessment, I would even debate if this is a bug to begin with 🙂 Let's discuss this with the team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ECK operator is indefinitely attempting to renew a user provided certificate

4 participants