Skip to content

Add support for CLI flag for mTLS client certificate key passphrase#5494

Merged
AndersonQ merged 1 commit intoelastic:mainfrom
AndersonQ:5489-client-cert-key-passphrase
Sep 20, 2024
Merged

Add support for CLI flag for mTLS client certificate key passphrase#5494
AndersonQ merged 1 commit intoelastic:mainfrom
AndersonQ:5489-client-cert-key-passphrase

Conversation

@AndersonQ
Copy link
Copy Markdown
Member

@AndersonQ AndersonQ commented Sep 10, 2024

What does this PR do?

It adds support for encrypted client certificate key during install/enroll, which done by the cli flag --elastic-agent-cert-key-passphrase.

Why is it important?

It enables Elastic Agent to be configured with passphrase-protected private keys for client mTLS certificates.

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

Author's checklist

Tests

  • Ensure --elastic-agent-cert-key-passphrase adheres to the same requirements as --fleet-server-cert-key-passphrase.
  • Verify that both --elastic-agent-cert-key and --elastic-agent-cert are provided when --elastic-agent-cert-key-passphrase is present.
  • Confirm that *enrollCmdOption.remoteConfig() accurately incorporates the passphrase into tlscommon.CertificateConfig.
  • Validate that fleetclient.NewWithConfig generates a valid client capable of establishing an mTLS connection to a mock server.
  • Ensure the policy TLS client settings take precedence over the CLI. Extend policy with SSL config to ensure the client certificate key passphrase from the cli is not left in the config when the policy's client client certificate key is not passphrase-protected.

Disruptive User Impact

  • None

How to test this PR locally

  • Build Elastic Agent with the changes from this PR.
  • Enroll/Install the Elastic Agent using passphrase-protected private key for the client mTLS certificate.
  • Start Elastic Agent and observe successful enrollment/installation with mTLS enabled.

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?
  • ...

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 10, 2024

This pull request does not have a backport label. Could you fix it @AndersonQ? 🙏
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

backport-v8.x has been added to help with the transition to the new branch 8.x.

@AndersonQ AndersonQ force-pushed the 5489-client-cert-key-passphrase branch 2 times, most recently from 5c9c606 to 3351e32 Compare September 11, 2024 07:43
@AndersonQ AndersonQ changed the title wip - just letting the tests run Add support for CLI flag for mTLS client certificate key passphrase Sep 11, 2024
@AndersonQ AndersonQ force-pushed the 5489-client-cert-key-passphrase branch from cd98d59 to 2c94c5b Compare September 11, 2024 08:40
Comment on lines +625 to +626
absPath, err := filepath.Abs("/path/to/token")
require.NoError(t, err, "could not get absolute absPath")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I honestly do not know why it was working on windows before, but it started to fail on elastic-agent-cert-key does not require key-passphrase, so I fixed all tests.

@AndersonQ AndersonQ marked this pull request as ready for review September 11, 2024 08:48
@AndersonQ AndersonQ requested a review from a team as a code owner September 11, 2024 08:48
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 11, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Sep 11, 2024
@v1v v1v removed the backport-v8.x label Sep 11, 2024
@AndersonQ AndersonQ force-pushed the 5489-client-cert-key-passphrase branch from cbdb682 to 1fa216d Compare September 12, 2024 08:54
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Sep 16, 2024
@elasticmachine
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@michel-laterman michel-laterman left a comment

Choose a reason for hiding this comment

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

lgtm

@AndersonQ AndersonQ enabled auto-merge (squash) September 18, 2024 06:12
It adds support for encrypted client certificate key during install/enroll, which done by the cli flag `--elastic-agent-cert-key-passphrase`.
@ycombinator ycombinator force-pushed the 5489-client-cert-key-passphrase branch from c4dcbdf to 4d283ea Compare September 20, 2024 00:40
@elastic-sonarqube
Copy link
Copy Markdown

@AndersonQ AndersonQ merged commit 346e5be into elastic:main Sep 20, 2024
mergify bot pushed a commit that referenced this pull request Sep 20, 2024
…5494)

It adds support for encrypted client certificate key during install/enroll, which done by the cli flag `--elastic-agent-cert-key-passphrase`.

(cherry picked from commit 346e5be)
pierrehilbert pushed a commit that referenced this pull request Sep 23, 2024
…5494) (#5574)

It adds support for encrypted client certificate key during install/enroll, which done by the cli flag `--elastic-agent-cert-key-passphrase`.

(cherry picked from commit 346e5be)

Co-authored-by: Anderson Queiroz <anderson.queiroz@elastic.co>
belimawr pushed a commit to belimawr/elastic-agent that referenced this pull request Sep 27, 2024
…lastic#5494)

It adds support for encrypted client certificate key during install/enroll, which done by the cli flag `--elastic-agent-cert-key-passphrase`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.x Automated backport to the 8.x branch with mergify 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.

Add support for CLI flag for mTLS client certificate key passphrase

5 participants