Skip to content

feat(dane): add DANE TLSA cert push support for alt-root domains (e.g. HNS) - #10

Draft
pcfreak30 wants to merge 1 commit into
developfrom
alt-root-domains
Draft

feat(dane): add DANE TLSA cert push support for alt-root domains (e.g. HNS)#10
pcfreak30 wants to merge 1 commit into
developfrom
alt-root-domains

Conversation

@pcfreak30

@pcfreak30 pcfreak30 commented Jul 25, 2026

Copy link
Copy Markdown
Member

Adds DANE TLSA certificate push support for alt-root domains (Handshake/HNS) in the cert-webhook.

  • Detects single-label DANE domains via IsDaneDomain
  • On cert issuance, pushes PEM to portal /internal/dns/cert so portal can store TLSA
  • Uses go.lumeweb.com/dane for SPKI/TLSA computation (no reinvention)
  • Renamed from hns→dane internally; removed unused HNS_GATEWAY_DOMAIN
  • 49 tests pass

This is the Caddy-side half of the DANE/alt-root flow (portal HNSProvider handles delegation modes).


Summary

This PR adds DANE TLSA certificate push support for alternative-root domains (e.g., Handshake Name System / HNS). When a certificate event occurs for a single-label domain (a domain without a dot, such as example), the plugin now extracts the certificate and pushes it to the portal's /internal/dns/cert endpoint so the portal can compute and publish the corresponding TLSA record.

Changes

  • New dane.go module: Introduces DANECertManager, which:

    • Identifies DANE-relevant domains via IsDaneDomain (single-label, no dot).
    • Pushes certificate PEM data to the portal's internal DNS cert endpoint.
    • Computes a local TLSA record using the go.lumeweb.com/dane library.
  • Event handling integration: handleCertEvent now checks if the certificate domain is a DANE alt-root domain. If so, it extracts the certificate PEM from Caddy's certificate cache and asynchronously pushes it to the portal.

  • Certificate extraction: Added extractCertPEM to retrieve the matching certificate from caddytls.AllMatchingCertificates and encode it as PEM.

  • Manager lifecycle: CertWebhookApp now initializes a DANECertManager on startup using the configured portal URL and gateway secret.

  • Tests: Added dane_test.go covering domain detection, TLSA computation, successful cert push, and error handling for failed/unreachable portal responses.

@kody-ai

This comment has been minimized.

Comment thread dane.go
Comment thread dane.go
Comment thread dane_test.go
Comment thread events.go
Comment thread events.go Outdated
Comment thread events.go Outdated

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@kody-ai

This comment has been minimized.

Comment thread dane.go Outdated
Comment thread events.go Outdated
Comment thread events.go

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Found critical issues please review the requested changes

@kody-ai

This comment has been minimized.

Comment thread dane.go
Comment thread dane_manager.go Outdated
Comment thread dane_manager.go Outdated
Comment thread dane_test.go

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@kody-ai

kody-ai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: Unexpected error while running the code review (openai_compatible).

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

Comment thread dane_checker.go
return false, "", fmt.Errorf("create request: %w", err)
}

req.Header.Set("X-Gateway-Secret", d.gatewaySecret)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules critical

Hard-coded header key "X-Gateway-Secret" in dane_checker.go contains the keyword "Secret", so the secret-detection policy flags this line as a hard-coded secret even though only the header name is static. Load the header name from os.Getenv, viper, or koanf, or rename it to omit "Secret"; also confirm the gateway secret value itself is sourced from an approved configuration call at the call site.

Kody rule violation: Ban hard-coded secrets in Go source

Prompt for LLM

File dane_checker.go:

Line 50:

Hard-coded header key "X-Gateway-Secret" in dane_checker.go contains the keyword "Secret", so the secret-detection policy flags this line as a hard-coded secret even though only the header name is static. Load the header name from os.Getenv, viper, or koanf, or rename it to omit "Secret"; also confirm the gateway secret value itself is sourced from an approved configuration call at the call site.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant