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

Fix issue building urls with IPv6 IPs for ACME http-01 challenges #28718

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

stevendpclark
Copy link
Contributor

@stevendpclark stevendpclark commented Oct 16, 2024

Description

  • We weren't properly encapsulating the IPv6 IP within the URL provided to the http client with [].
  • Validate using netip.ParseAddr if we are a proper IPv6 address.
    • We aren't using net.IP.ToIPv4 as that will return true for IPv4 addresses encoded within an IPv6 ::ffff: prefix
  • Even though the ACME new order handler will prohibit zone'd IPv6 addresses, we fix the URL encoding of the IPv6 address being sent into the http client to surround the escaped value in [] and encode the % with %25 in case we ever change that logic.
# ./acme.sh --issue --standalone --server http://127.0.0.1:8200/v1/pki/acme/directory --listen-v6 --domain 2600:1f11:482:a409:7dd4:59ab:ea06:b516
[Wed Oct 16 14:35:47 UTC 2024] Using CA: http://127.0.0.1:8200/v1/pki/acme/directory
[Wed Oct 16 14:35:47 UTC 2024] Standalone mode.
[Wed Oct 16 14:35:47 UTC 2024] Single domain='2600:1f11:482:a409:7dd4:59ab:ea06:b516'
[Wed Oct 16 14:35:48 UTC 2024] Getting webroot for domain='2600:1f11:482:a409:7dd4:59ab:ea06:b516'
[Wed Oct 16 14:35:48 UTC 2024] Verifying: 2600:1f11:482:a409:7dd4:59ab:ea06:b516
[Wed Oct 16 14:35:48 UTC 2024] Standalone mode server
[Wed Oct 16 14:35:49 UTC 2024] Processing. The CA is processing your order, please wait. (1/30)
[Wed Oct 16 14:35:53 UTC 2024] Success
[Wed Oct 16 14:35:53 UTC 2024] Verification finished, beginning signing.
[Wed Oct 16 14:35:53 UTC 2024] Let's finalize the order.
[Wed Oct 16 14:35:53 UTC 2024] Le_OrderFinalize='http://127.0.0.1:8200/v1/pki/acme/order/0434cc5a-12ab-e387-b778-e70f0565f0b0/finalize'
[Wed Oct 16 14:35:53 UTC 2024] Downloading cert.
[Wed Oct 16 14:35:53 UTC 2024] Le_LinkCert='http://127.0.0.1:8200/v1/pki/acme/order/0434cc5a-12ab-e387-b778-e70f0565f0b0/cert'
[Wed Oct 16 14:35:53 UTC 2024] Cert success.
-----BEGIN CERTIFICATE-----
MIIBijCCATGgAwIBAgIUJ2uTAyFmWNYIwGOg2LSmEEC7K9kwCgYIKoZIzj0EAwIw
ADAeFw0yNDEwMTYxNDM1MjNaFw0yNDExMTcxNDIzMTJaMAAwWTATBgcqhkjOPQIB
BggqhkjOPQMBBwNCAAQSvFrdCDhynV595SItJnIPRM2xqyIBDuSL4w+L8WEvabMS
grf9zu5ohhvGzpMqt0FJ7mM788slbWQDQtRmp28yo4GIMIGFMA4GA1UdDwEB/wQE
AwIDqDATBgNVHSUEDDAKBggrBgEFBQcDATAdBgNVHQ4EFgQUd4dH309Uz6JXRFP/
DwkugsBT+kcwHwYDVR0jBBgwFoAUvPO4X7eb8zbJZ9nXKJYgYKK/QhowHgYDVR0R
AQH/BBQwEocQJgAfEQSCpAl91Fmr6ga1FjAKBggqhkjOPQQDAgNHADBEAiAq1i9G
6mkNYP4/xEFYD4N/yKZ8zghWfDoYQXUtAHttlAIgZIf03dPKRbE7SRaLSBjY8NPr
bbUPO+P3heQ/I+3wMLA=
-----END CERTIFICATE-----
[Wed Oct 16 14:35:53 UTC 2024] Your cert is in: /root/.acme.sh/2600:1f11:482:a409:7dd4:59ab:ea06:b516_ecc/2600:1f11:482:a409:7dd4:59ab:ea06:b516.cer
[Wed Oct 16 14:35:53 UTC 2024] Your cert key is in: /root/.acme.sh/2600:1f11:482:a409:7dd4:59ab:ea06:b516_ecc/2600:1f11:482:a409:7dd4:59ab:ea06:b516.key
[Wed Oct 16 14:35:53 UTC 2024] The intermediate CA cert is in: /root/.acme.sh/2600:1f11:482:a409:7dd4:59ab:ea06:b516_ecc/ca.cer
[Wed Oct 16 14:35:53 UTC 2024] And the full-chain cert is in: /root/.acme.sh/2600:1f11:482:a409:7dd4:59ab:ea06:b516_ecc/fullchain.cer

TODO only if you're a HashiCorp employee

  • Backport Labels: If this PR is in the ENT repo and needs to be backported, backport
    to N, N-1, and N-2, using the backport/ent/x.x.x+ent labels. If this PR is in the CE repo, you should only backport to N, using the backport/x.x.x label, not the enterprise labels.
    • If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

 - We weren't properly encapsulating the IPv6 IP within the url provided
   to the http client with [].
@stevendpclark stevendpclark added secret/pki backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/1.18.x backport/ent/1.17.x+ent Changes are backported to 1.17.x+ent labels Oct 16, 2024
@stevendpclark stevendpclark added this to the 1.18.1 milestone Oct 16, 2024
@stevendpclark stevendpclark self-assigned this Oct 16, 2024
@stevendpclark stevendpclark requested a review from a team as a code owner October 16, 2024 14:44
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Oct 16, 2024
Copy link

github-actions bot commented Oct 16, 2024

Build Results:
All builds succeeded! ✅

Copy link

github-actions bot commented Oct 16, 2024

CI Results:
All Go tests succeeded! ✅

Copy link
Contributor

@victorr victorr left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

builtin/logical/pki/acme_challenge_engine_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kitography kitography left a comment

Choose a reason for hiding this comment

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

Looks great, very clean - well done

@stevendpclark stevendpclark merged commit bce085b into main Oct 16, 2024
91 checks passed
@stevendpclark stevendpclark deleted the stevendpclark/vault-31255-acme-ipv6-sans branch October 16, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/ent/1.17.x+ent Changes are backported to 1.17.x+ent backport/1.18.x hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed secret/pki
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants