[PR #5173] feat(trust): Add server trust establishment with CA install and certificate pinning (T-5.7) #25166

Open
opened 2026-08-05 06:09:37 -04:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/5173

State: closed
Merged: No


Summary

  • Add certificate pinning support (sha256//BASE64 format) for management server verification
  • Implement CA certificate installation to Windows Trusted Root store (certutil -addstore)
  • Support backup pins for certificate rotation scenarios
  • Add comprehensive unit tests for all pin verification scenarios

Changes

New Files

  • client/internal/tunnel/trust_windows.go - Windows implementation with CA install
  • client/internal/tunnel/trust_other.go - Non-Windows stub (pinning only)
  • client/internal/tunnel/trust_test.go - Unit tests (17 test cases)

Key Functions

Function Purpose
VerifyServerCert() TLS verification callback with pinning support
InstallCACert() Install CA to Windows Trusted Root store
RemoveCACert() Remove CA by thumbprint (cleanup)
GetCertPin() Calculate SHA-256 pin from file/bytes/x509
TrustBootstrap() Complete trust establishment workflow

Configuration

# Option 1: CA Certificate Installation
management_ca_cert: "C:\\ProgramData\\NetBird\\mgmt-ca.crt"

# Option 2: Certificate Pinning (tighter security)
management_cert_pin: "sha256//ABC123..."
management_cert_pin_backup: "sha256//XYZ789..."  # For rotation

Test plan

  • Unit tests pass locally (go test ./client/internal/tunnel/...)
  • go vet passes
  • CI tests pass
  • Integration test: Bootstrap with pinned certificate

Closes #53

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/netbirdio/netbird/pull/5173 **State:** closed **Merged:** No --- ## Summary - Add certificate pinning support (`sha256//BASE64` format) for management server verification - Implement CA certificate installation to Windows Trusted Root store (`certutil -addstore`) - Support backup pins for certificate rotation scenarios - Add comprehensive unit tests for all pin verification scenarios ## Changes ### New Files - `client/internal/tunnel/trust_windows.go` - Windows implementation with CA install - `client/internal/tunnel/trust_other.go` - Non-Windows stub (pinning only) - `client/internal/tunnel/trust_test.go` - Unit tests (17 test cases) ### Key Functions | Function | Purpose | |----------|---------| | `VerifyServerCert()` | TLS verification callback with pinning support | | `InstallCACert()` | Install CA to Windows Trusted Root store | | `RemoveCACert()` | Remove CA by thumbprint (cleanup) | | `GetCertPin()` | Calculate SHA-256 pin from file/bytes/x509 | | `TrustBootstrap()` | Complete trust establishment workflow | ### Configuration ```yaml # Option 1: CA Certificate Installation management_ca_cert: "C:\\ProgramData\\NetBird\\mgmt-ca.crt" # Option 2: Certificate Pinning (tighter security) management_cert_pin: "sha256//ABC123..." management_cert_pin_backup: "sha256//XYZ789..." # For rotation ``` ## Test plan - [x] Unit tests pass locally (`go test ./client/internal/tunnel/...`) - [x] `go vet` passes - [ ] CI tests pass - [ ] Integration test: Bootstrap with pinned certificate ## Related Closes #53 🤖 Generated with [Claude Code](https://claude.com/claude-code)
saavagebueno added the pull-request label 2026-08-05 06:09:37 -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#25166