Skip to content

telemetry: generate DPU ephemeral TLS certificates - #772

Open
hdwhdw wants to merge 2 commits into
sonic-net:masterfrom
hdwhdw:fix/dpu-ephemeral-tls-certificate
Open

telemetry: generate DPU ephemeral TLS certificates#772
hdwhdw wants to merge 2 commits into
sonic-net:masterfrom
hdwhdw:fix/dpu-ephemeral-tls-certificate

Conversation

@hdwhdw

@hdwhdw hdwhdw commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Why

The SmartSwitch DPU launcher selects telemetry --insecure when no server certificate is configured. The generic --insecure path calls testdata/tls.NewCert().

The generated certificate contains only the example.com SAN and expires after one hour. A Python gRPC client cannot verify a DPU IP address against the certificate.

References

What

  • telemetry adds --dpu_ephemeral_tls and leaves generic --insecure behavior unchanged.
  • The mode generates a process-local, self-signed certificate with the DPU's current non-loopback IP addresses and hostname as SANs. The mode does not hard-code a midplane address.
  • Address discovery accepts both CIDR and direct IP values returned by net.InterfaceAddrs().
  • The mode sets NotBefore to five minutes before generation and uses a ten-year certificate lifetime. telemetry generates a new key and certificate on each restart.
  • When another TLS mode or server key pair is configured, telemetry rejects --dpu_ephemeral_tls.
  • The mode does not change client authentication or authz policy selection.

Validation

  • go test -race ./pkg/dpuephemeraltls
  • go test -count=10 ./pkg/dpuephemeraltls
  • go vet ./pkg/dpuephemeraltls
  • The package tests include a TLS handshake with server verification by IP address.

Security scope

The mode encrypts transport and provides a leaf certificate that clients can pin. The certificate does not provide CA-backed DPU identity.

Restart telemetry after a DPU IP address changes to regenerate the certificate.

Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
Copilot AI lite review requested due to automatic review settings August 28, 2026 16:13
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 a new telemetry TLS mode intended for SmartSwitch DPU deployments: it generates a process-local, self-signed server certificate whose SANs include the DPU’s current non-loopback IP addresses (plus hostname) so clients (including Python gRPC) can verify by IP address without requiring a pre-provisioned keypair.

Changes:

  • Add --dpu_ephemeral_tls flag and reject invalid flag combinations (--insecure, --noTLS, or explicit --server_crt/--server_key).
  • Generate and serve a fresh self-signed certificate/key at startup when --dpu_ephemeral_tls is enabled.
  • Introduce pkg/dpuephemeraltls with unit tests including a TLS handshake that verifies the server cert by IP SAN.

Reviewed changes

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

File Description
telemetry/telemetry.go Adds the new DPU ephemeral TLS mode flag, validates conflicts, and wires certificate generation into server startup.
telemetry/telemetry_test.go Extends flag parsing tests to cover the new mode and its conflict rules.
pkg/dpuephemeraltls/certificate.go Implements self-signed cert generation using current host IPs/hostname as SANs.
pkg/dpuephemeraltls/certificate_test.go Tests SAN contents, lifetime, error cases, and a verified TLS handshake by IP.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +32 to +42
for _, addr := range addrs {
ip, _, err := net.ParseCIDR(addr.String())
if err != nil || ip.IsLoopback() || ip.IsUnspecified() {
continue
}
key := ip.String()
if !seen[key] {
seen[key] = true
ipAddresses = append(ipAddresses, ip)
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Handled in e3373cc. Address discovery now supports both *net.IPNet and *net.IPAddr, with test coverage for the direct IP form.

Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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.

3 participants