Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply mTLS config from policy #4770

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

pchila
Copy link
Contributor

@pchila pchila commented May 16, 2024

What does this PR do?

This PR implements reading and applying TLS configuration for Fleet client using CA, certificate and key included in Fleet policy.

This PR:

Note to reviewers: refactor of ProxyURL integration tests has been moved to PR #4813 , so for initial review you can have a look at this set of commits or wait till PR #4813 is merged and this PR rebased onto the new main

Why is it important?

Configuring TLS via the policy allows agent to connect to Fleet (possibly via a proxy) using custom CAs or enabling mTLS (certificate verification of both the client and the server).

Checklist

  • My code follows the style guidelines of this project
  • 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
  • I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

In order to test this PR we need:

  • fleet server or proxy with TLS (or mTLS) configured using custom CAs and certificates signed by such CAs (left as exercise to the reader)
  • Make sure that the agent can connect to fleet for enrolling without custom CAs or certificates.
  • enroll agent with a simple policy
  • Add Custom CAs and or key + certificates for the agent to use along with a new URL (maybe a proxy) pointing to where TLS has been configured.
  • Verify that the agent can connect correctly using CAs (and Certificate/Key in case of mTLS)

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@pchila pchila added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent Label for the Agent team labels May 16, 2024
@pchila pchila self-assigned this May 16, 2024
Copy link
Contributor

mergify bot commented May 16, 2024

This pull request does not have a backport label. Could you fix it @pchila? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

Copy link
Contributor

mergify bot commented May 20, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b apply-mTLS-config-from-policy upstream/apply-mTLS-config-from-policy
git merge upstream/main
git push upstream apply-mTLS-config-from-policy

@pchila pchila force-pushed the apply-mTLS-config-from-policy branch 3 times, most recently from d51dcc1 to a457ba3 Compare May 23, 2024 14:37
@pchila pchila marked this pull request as ready for review May 23, 2024 14:38
@pchila pchila requested a review from a team as a code owner May 23, 2024 14:38
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@pchila pchila requested review from cmacknz and blakerouse May 23, 2024 14:38
@pchila pchila force-pushed the apply-mTLS-config-from-policy branch from 5b7af1a to bd9fe64 Compare May 24, 2024 11:28
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: bug-fix
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, mTLS (Agent presenting a certificate to Fleet Server / proxy) is a new feature, so this should probably be feature or enhancement?

Suggested change
kind: bug-fix
kind: feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue #2247 is flagged as bug so I put this as bug-fix... this changelog is related to reading Certificate Authorities from fleet policy, the other fragment is for presenting a certificate to Fleet server.

The other fragment is also flagged as bug-fix but that one is pointing to #2248 which is labeled as enhancement

Copy link
Contributor

Choose a reason for hiding this comment

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

Ha, I think both should be enhancements but this is probably best decided by @nimarezainia.

kind: bug-fix

# Change summary; a 80ish characters long description of the change.
summary: Load fleet.ssl.certificate_authorities from agent policy
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rephrase this in more end-user-friendly terms?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip bug Something isn't working Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
3 participants