[PR #5491] [CLOSED] Add internal Certificate Authority for peer TLS certificates #28034

Closed
opened 2026-08-05 07:09:34 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5491
Author: @zgv163
Created: 3/3/2026
Status: Closed

Base: mainHead: feature/internal-ca


📝 Commits (10+)

  • 10a1c38 [management] Add internal CA module with signing and storage
  • 8b9fed2 [management] Add proto definitions for certificate signing
  • fa6f499 [management] Implement certificate signing gRPC handlers
  • f3c701d [client] Add proto definitions for certificate daemon RPCs
  • 6e07970 [client] Add certificate manager and platform trust store
  • ca8e49f [client] Add daemon handlers and CLI for certificate management
  • 026b7a2 [client] Add CA distribution via sync and certificate auto-renewal
  • a25ee9c [management] Add CA REST API and permission module
  • d247733 [management] Add CA OpenAPI spec, REST client, and use generated types
  • e211cfd [management] Wire CA into black-box test server and add integration test

📊 Changes

56 files changed (+19166 additions, -483 deletions)

View changed files

client/cmd/cert.go (+172 -0)
📝 client/cmd/root.go (+7 -0)
client/internal/cert/manager.go (+245 -0)
client/internal/cert/manager_test.go (+214 -0)
client/internal/cert/trust_darwin.go (+87 -0)
client/internal/cert/trust_linux.go (+146 -0)
client/internal/cert/trust_windows.go (+85 -0)
📝 client/internal/connect.go (+15 -0)
📝 client/internal/engine.go (+168 -0)
📝 client/proto/daemon.pb.go (+748 -225)
📝 client/proto/daemon.proto (+53 -0)
📝 client/proto/daemon_grpc.pb.go (+152 -0)
client/server/cert.go (+320 -0)
📝 client/server/server.go (+17 -1)
📝 management/internals/controllers/network_map/controller/controller.go (+22 -6)
📝 management/internals/controllers/network_map/controller/repository.go (+5 -0)
📝 management/internals/server/boot.go (+4 -1)
📝 management/internals/server/modules.go (+9 -0)
management/internals/shared/grpc/cert_service.go (+230 -0)
📝 management/internals/shared/grpc/conversion.go (+5 -4)

...and 36 more files

📄 Description

Describe your changes

Adds a built-in Certificate Authority to NetBird that issues TLS certificates for peer hostnames, eliminating browser security warnings when accessing services over NetBird peer domains.

Management server:

  • Internal CA module with ECDSA P-256 root certificate generation, constrained to the account's DNS domain via x509 NameConstraints
  • Certificate signing via gRPC with CSR-based flow (peer private keys never leave the device)
  • CA initialization with configurable display name, organization, and validity period
  • CA rotation (creates new CA alongside existing one for graceful transition; old CA can be deactivated after distribution)
  • Certificate revocation by serial number
  • REST API and OpenAPI spec for CA management and issued certificates
  • Wildcard DNS record support for peers with wildcard certificates
  • Permission module for certificate authority operations
  • Certificate validity tied to peer login expiration
  • Integration tests wired into the black-box test server

Client:

  • netbird cert request — request a TLS certificate (supports --wildcard flag)
  • netbird cert status — show current certificate details
  • netbird cert trust-ca — install CA into OS trust store
  • netbird cert untrust-ca — remove CA from OS trust store
  • Certificate auto-renewal before expiry
  • CA distribution via management sync
  • Platform trust store integration (macOS, Linux, Windows)
  • Proto definitions for certificate daemon RPCs and gRPC signing

Account settings:

  • cert_wildcard_allowed setting to control whether peers can request wildcard certificates

Closes https://github.com/netbirdio/netbird/issues/5479

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/643

Companion PRs:

Summary by CodeRabbit

  • New Features

    • Full certificate lifecycle: request/status/trust/untrust via CLI, automatic renewal, wildcard support, and OS CA trust on macOS/Linux/Windows.
    • CA management API/UI: initialize, rotate, deactivate CAs; list/revoke issued certificates; CA certs propagated to peers.
  • Tests

    • Extensive unit and integration tests covering certificate manager, CA manager, signers, gRPC/HTTP handlers, CLI and end-to-end flows.
  • Other

    • Per-peer rate limiting and activity events for certificate operations.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/5491 **Author:** [@zgv163](https://github.com/zgv163) **Created:** 3/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/internal-ca` --- ### 📝 Commits (10+) - [`10a1c38`](https://github.com/netbirdio/netbird/commit/10a1c38b7d2d3a9ff79ae8be87a940c43e389271) [management] Add internal CA module with signing and storage - [`8b9fed2`](https://github.com/netbirdio/netbird/commit/8b9fed2c3f761de1923a3f24703b407f8c741207) [management] Add proto definitions for certificate signing - [`fa6f499`](https://github.com/netbirdio/netbird/commit/fa6f4997ddb617f0289febcfc3cc47efd801735e) [management] Implement certificate signing gRPC handlers - [`f3c701d`](https://github.com/netbirdio/netbird/commit/f3c701de1c862056d8057fed7dcd6a8c48dcbb28) [client] Add proto definitions for certificate daemon RPCs - [`6e07970`](https://github.com/netbirdio/netbird/commit/6e07970cf4e1de9a00240fff3fce8e045414dc69) [client] Add certificate manager and platform trust store - [`ca8e49f`](https://github.com/netbirdio/netbird/commit/ca8e49fe2631dd20d474a5f82921b1156ef119e5) [client] Add daemon handlers and CLI for certificate management - [`026b7a2`](https://github.com/netbirdio/netbird/commit/026b7a29cbfe2df24e4c067213c292ac922b8271) [client] Add CA distribution via sync and certificate auto-renewal - [`a25ee9c`](https://github.com/netbirdio/netbird/commit/a25ee9c92961d1e9a526892d2a4a5023eb974d23) [management] Add CA REST API and permission module - [`d247733`](https://github.com/netbirdio/netbird/commit/d24773356833b173736812ae945fd3d23b226ce0) [management] Add CA OpenAPI spec, REST client, and use generated types - [`e211cfd`](https://github.com/netbirdio/netbird/commit/e211cfdbfdf7db09b2a640471c555f14516c4db4) [management] Wire CA into black-box test server and add integration test ### 📊 Changes **56 files changed** (+19166 additions, -483 deletions) <details> <summary>View changed files</summary> ➕ `client/cmd/cert.go` (+172 -0) 📝 `client/cmd/root.go` (+7 -0) ➕ `client/internal/cert/manager.go` (+245 -0) ➕ `client/internal/cert/manager_test.go` (+214 -0) ➕ `client/internal/cert/trust_darwin.go` (+87 -0) ➕ `client/internal/cert/trust_linux.go` (+146 -0) ➕ `client/internal/cert/trust_windows.go` (+85 -0) 📝 `client/internal/connect.go` (+15 -0) 📝 `client/internal/engine.go` (+168 -0) 📝 `client/proto/daemon.pb.go` (+748 -225) 📝 `client/proto/daemon.proto` (+53 -0) 📝 `client/proto/daemon_grpc.pb.go` (+152 -0) ➕ `client/server/cert.go` (+320 -0) 📝 `client/server/server.go` (+17 -1) 📝 `management/internals/controllers/network_map/controller/controller.go` (+22 -6) 📝 `management/internals/controllers/network_map/controller/repository.go` (+5 -0) 📝 `management/internals/server/boot.go` (+4 -1) 📝 `management/internals/server/modules.go` (+9 -0) ➕ `management/internals/shared/grpc/cert_service.go` (+230 -0) 📝 `management/internals/shared/grpc/conversion.go` (+5 -4) _...and 36 more files_ </details> ### 📄 Description ## Describe your changes Adds a built-in Certificate Authority to NetBird that issues TLS certificates for peer hostnames, eliminating browser security warnings when accessing services over NetBird peer domains. **Management server:** - Internal CA module with ECDSA P-256 root certificate generation, constrained to the account's DNS domain via x509 NameConstraints - Certificate signing via gRPC with CSR-based flow (peer private keys never leave the device) - CA initialization with configurable display name, organization, and validity period - CA rotation (creates new CA alongside existing one for graceful transition; old CA can be deactivated after distribution) - Certificate revocation by serial number - REST API and OpenAPI spec for CA management and issued certificates - Wildcard DNS record support for peers with wildcard certificates - Permission module for certificate authority operations - Certificate validity tied to peer login expiration - Integration tests wired into the black-box test server **Client:** - `netbird cert request` — request a TLS certificate (supports `--wildcard` flag) - `netbird cert status` — show current certificate details - `netbird cert trust-ca` — install CA into OS trust store - `netbird cert untrust-ca` — remove CA from OS trust store - Certificate auto-renewal before expiry - CA distribution via management sync - Platform trust store integration (macOS, Linux, Windows) - Proto definitions for certificate daemon RPCs and gRPC signing **Account settings:** - `cert_wildcard_allowed` setting to control whether peers can request wildcard certificates ## Issue ticket number and link Closes https://github.com/netbirdio/netbird/issues/5479 ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/643 **Companion PRs:** - Dashboard UI: https://github.com/netbirdio/dashboard/pull/574 - Documentation: https://github.com/netbirdio/docs/pull/643 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Full certificate lifecycle: request/status/trust/untrust via CLI, automatic renewal, wildcard support, and OS CA trust on macOS/Linux/Windows. * CA management API/UI: initialize, rotate, deactivate CAs; list/revoke issued certificates; CA certs propagated to peers. * **Tests** * Extensive unit and integration tests covering certificate manager, CA manager, signers, gRPC/HTTP handlers, CLI and end-to-end flows. * **Other** * Per-peer rate limiting and activity events for certificate operations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:09:34 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#28034