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

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

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

State: closed
Merged: No


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.

**Original Pull Request:** https://github.com/netbirdio/netbird/pull/5178 **State:** closed **Merged:** No --- ## 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 -->
saavagebueno added the pull-request label 2026-08-05 06:05:48 -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#22294