[PR #5178] [CLOSED] feat(tunnel): Add mTLS authentication tests (T-6.2) #25182

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5178
Author: @obtFusi
Created: 1/25/2026
Status: Closed

Base: mainHead: feature/t-6.2-mtls-auth-tests


📝 Commits (10+)

  • dfcaebe ci: add GitHub configuration from network-agent pattern
  • 3d1defe Merge pull request #1 from obtFusi/ci/github-config
  • b036814 feat(auth): Add mTLS authentication for Machine Tunnel (S-1 Spikes)
  • 634bd3c chore: add AUDIT files to gitignore
  • 5357588 feat(spike): Add S-1 Windows mTLS spikes - CNG signer and SAN parser
  • e594b07 feat(lab): Add CA bootstrap and verification scripts
  • f52cd3d fix(lab): Fix verify-lab-ca.ps1 parsing bugs
  • 6f72ca7 feat(proto): Generate Go code for Machine Tunnel RPCs
  • a4deec3 feat(mtls): Add per-account AllowedDomains for multi-tenant isolation
  • 648b532 feat(mtls): Add Machine Tunnel RPC handlers (T-3.6)

📊 Changes

75 files changed (+14093 additions, -1943 deletions)

View changed files

.githooks/pre-commit (+31 -0)
.github/ISSUE_TEMPLATE/bug_report.md (+29 -0)
.github/ISSUE_TEMPLATE/config.yml (+8 -0)
.github/ISSUE_TEMPLATE/epic.md (+39 -0)
📝 .github/ISSUE_TEMPLATE/feature_request.md (+2 -2)
.github/ISSUE_TEMPLATE/story.md (+32 -0)
.github/ISSUE_TEMPLATE/task.md (+31 -0)
.github/dependabot.yml (+31 -0)
.github/workflows/auto-label.yml (+97 -0)
.github/workflows/e2e-tunnel.yml (+154 -0)
.github/workflows/pr-lint.yml (+36 -0)
📝 .gitignore (+48 -1)
📝 Makefile (+51 -2)
client/internal/tunnel/bootstrap.go (+470 -0)
client/internal/tunnel/bootstrap_test.go (+319 -0)
client/internal/tunnel/certenroll.go (+451 -0)
client/internal/tunnel/certenroll_test.go (+540 -0)
client/internal/tunnel/cmd/mtlstest/main.go (+505 -0)
client/internal/tunnel/cmd/securitytest/main.go (+388 -0)
client/internal/tunnel/cmd/trusttest/main.go (+293 -0)

...and 55 more files

📄 Description

Summary

  • Add unit tests for mTLS certificate validation logic (TC19, TC21-TC23, TC27)
  • Add mtlstest E2E test binary for Windows VMs
  • Verify mTLS server infrastructure is ready (port 33074, CA loaded, domain mapping)

Test Cases Implemented

Test Beschreibung Status
TC19 Issuer-CA Validation (wrong CA rejected) Unit , E2E Tool
TC21 mTLS-Strict Method-Allowlist (no cert → Unauthenticated) E2E Tool
TC22 Multi-SAN AllowedDomains (evil.com + corp.local → corp.local accepted) Unit
TC23 Multi-SAN Rejection (only evil.com → rejected) Unit
TC27 Issuer-Fingerprint Validation (via VerifiedChains) Unit , E2E Tool

Unit Test Results

=== RUN   TestMTLSCertGeneration
--- PASS: TestMTLSCertGeneration (0.00s)
=== RUN   TestMTLSMultiSANValidation
    --- PASS: TC22: evil.com + corp.local → corp.local accepted
    --- PASS: TC23: only evil.com → rejected
--- PASS: TestMTLSMultiSANValidation (0.00s)
=== RUN   TestMTLSIssuerValidation
--- PASS: TestMTLSIssuerValidation (0.00s)

Infrastructure Verification

mTLS Server (10.0.0.103:33074):
✅ Port 33074 listening
✅ TLS handshake successful
✅ Server requests client certificate (Request CERT)
✅ CA certificate loaded (test-ca.crt)
✅ Domain mapping: test.local → d5pnitkcvkrc73eb6um0
✅ Issuer fingerprint: 42fecad0...

E2E Test Tool Usage

# On Windows VM
.\mtlstest.exe -server 10.0.0.103:33074
.\mtlstest.exe -server 10.0.0.103:33074 -test tc21
.\mtlstest.exe -server 10.0.0.103:33074 -ca .\test-ca.crt

Files Changed

  • client/internal/tunnel/mtls_test.go - Unit tests
  • client/internal/tunnel/cmd/mtlstest/main.go - E2E test binary

Closes #55

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added Windows Machine Tunnel bootstrap automation with two-phase authentication (Setup-Key and mTLS).
    • Added automated domain join and certificate enrollment for pre-login VPN scenarios.
    • Added mTLS-based authentication support for machine tunnel clients with certificate validation.
    • Added DC connectivity verification and pre-join requirement validation.
  • Documentation

    • Added architecture decision records for mTLS port strategy and certificate integration.
  • Chores

    • Enhanced CI/CD workflows with auto-labeling and linting for pull requests.

✏️ Tip: You can customize this high-level summary in your review settings.


🔄 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/5178 **Author:** [@obtFusi](https://github.com/obtFusi) **Created:** 1/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/t-6.2-mtls-auth-tests` --- ### 📝 Commits (10+) - [`dfcaebe`](https://github.com/netbirdio/netbird/commit/dfcaebe41c86a8aadccc35876b55a2f4d8361bed) ci: add GitHub configuration from network-agent pattern - [`3d1defe`](https://github.com/netbirdio/netbird/commit/3d1defea7cece943ec2b11e760478d0c524ae62b) Merge pull request #1 from obtFusi/ci/github-config - [`b036814`](https://github.com/netbirdio/netbird/commit/b036814fdcdf153323cefc3765c9fd40ae428084) feat(auth): Add mTLS authentication for Machine Tunnel (S-1 Spikes) - [`634bd3c`](https://github.com/netbirdio/netbird/commit/634bd3c19ec7831c3390ba88b3435f16ed626b87) chore: add AUDIT files to gitignore - [`5357588`](https://github.com/netbirdio/netbird/commit/535758810ff5885e4444ac30a8b54d7301844af4) feat(spike): Add S-1 Windows mTLS spikes - CNG signer and SAN parser - [`e594b07`](https://github.com/netbirdio/netbird/commit/e594b07f096b340c63b361b24e13d47105d39203) feat(lab): Add CA bootstrap and verification scripts - [`f52cd3d`](https://github.com/netbirdio/netbird/commit/f52cd3d7880e02974d826c5eeb8f55721beef64d) fix(lab): Fix verify-lab-ca.ps1 parsing bugs - [`6f72ca7`](https://github.com/netbirdio/netbird/commit/6f72ca78a1a3817d35ee4078ec2282ab55c61ea5) feat(proto): Generate Go code for Machine Tunnel RPCs - [`a4deec3`](https://github.com/netbirdio/netbird/commit/a4deec3109066e55f11c61f5d999df84a4c2ad4c) feat(mtls): Add per-account AllowedDomains for multi-tenant isolation - [`648b532`](https://github.com/netbirdio/netbird/commit/648b532034cf9d829fdfdad3dab6034fbf0e04a8) feat(mtls): Add Machine Tunnel RPC handlers (T-3.6) ### 📊 Changes **75 files changed** (+14093 additions, -1943 deletions) <details> <summary>View changed files</summary> ➕ `.githooks/pre-commit` (+31 -0) ➕ `.github/ISSUE_TEMPLATE/bug_report.md` (+29 -0) ➕ `.github/ISSUE_TEMPLATE/config.yml` (+8 -0) ➕ `.github/ISSUE_TEMPLATE/epic.md` (+39 -0) 📝 `.github/ISSUE_TEMPLATE/feature_request.md` (+2 -2) ➕ `.github/ISSUE_TEMPLATE/story.md` (+32 -0) ➕ `.github/ISSUE_TEMPLATE/task.md` (+31 -0) ➕ `.github/dependabot.yml` (+31 -0) ➕ `.github/workflows/auto-label.yml` (+97 -0) ➕ `.github/workflows/e2e-tunnel.yml` (+154 -0) ➕ `.github/workflows/pr-lint.yml` (+36 -0) 📝 `.gitignore` (+48 -1) 📝 `Makefile` (+51 -2) ➕ `client/internal/tunnel/bootstrap.go` (+470 -0) ➕ `client/internal/tunnel/bootstrap_test.go` (+319 -0) ➕ `client/internal/tunnel/certenroll.go` (+451 -0) ➕ `client/internal/tunnel/certenroll_test.go` (+540 -0) ➕ `client/internal/tunnel/cmd/mtlstest/main.go` (+505 -0) ➕ `client/internal/tunnel/cmd/securitytest/main.go` (+388 -0) ➕ `client/internal/tunnel/cmd/trusttest/main.go` (+293 -0) _...and 55 more files_ </details> ### 📄 Description ## Summary - Add unit tests for mTLS certificate validation logic (TC19, TC21-TC23, TC27) - Add `mtlstest` E2E test binary for Windows VMs - Verify mTLS server infrastructure is ready (port 33074, CA loaded, domain mapping) ## Test Cases Implemented | Test | Beschreibung | Status | |------|--------------|--------| | **TC19** | Issuer-CA Validation (wrong CA rejected) | Unit ✅, E2E Tool ✅ | | **TC21** | mTLS-Strict Method-Allowlist (no cert → Unauthenticated) | E2E Tool ✅ | | **TC22** | Multi-SAN AllowedDomains (evil.com + corp.local → corp.local accepted) | Unit ✅ | | **TC23** | Multi-SAN Rejection (only evil.com → rejected) | Unit ✅ | | **TC27** | Issuer-Fingerprint Validation (via VerifiedChains) | Unit ✅, E2E Tool ✅ | ## Unit Test Results ``` === RUN TestMTLSCertGeneration --- PASS: TestMTLSCertGeneration (0.00s) === RUN TestMTLSMultiSANValidation --- PASS: TC22: evil.com + corp.local → corp.local accepted --- PASS: TC23: only evil.com → rejected --- PASS: TestMTLSMultiSANValidation (0.00s) === RUN TestMTLSIssuerValidation --- PASS: TestMTLSIssuerValidation (0.00s) ``` ## Infrastructure Verification ``` mTLS Server (10.0.0.103:33074): ✅ Port 33074 listening ✅ TLS handshake successful ✅ Server requests client certificate (Request CERT) ✅ CA certificate loaded (test-ca.crt) ✅ Domain mapping: test.local → d5pnitkcvkrc73eb6um0 ✅ Issuer fingerprint: 42fecad0... ``` ## E2E Test Tool Usage ```powershell # On Windows VM .\mtlstest.exe -server 10.0.0.103:33074 .\mtlstest.exe -server 10.0.0.103:33074 -test tc21 .\mtlstest.exe -server 10.0.0.103:33074 -ca .\test-ca.crt ``` ## Files Changed - `client/internal/tunnel/mtls_test.go` - Unit tests - `client/internal/tunnel/cmd/mtlstest/main.go` - E2E test binary Closes #55 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Windows Machine Tunnel bootstrap automation with two-phase authentication (Setup-Key and mTLS). * Added automated domain join and certificate enrollment for pre-login VPN scenarios. * Added mTLS-based authentication support for machine tunnel clients with certificate validation. * Added DC connectivity verification and pre-join requirement validation. * **Documentation** * Added architecture decision records for mTLS port strategy and certificate integration. * **Chores** * Enhanced CI/CD workflows with auto-labeling and linting for pull requests. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- 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 06:09:38 -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#25182