mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-25 19:56:46 +00:00
add cert manager with self signed cert support
This commit is contained in:
@@ -56,15 +56,24 @@ func (p *Proxy) AddRoute(route *RouteConfig) error {
|
||||
// Add route with domain as key
|
||||
p.routes[route.Domain] = route
|
||||
|
||||
// Register domain with certificate manager
|
||||
p.certManager.AddDomain(route.Domain)
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"route_id": route.ID,
|
||||
"domain": route.Domain,
|
||||
"paths": len(route.PathMappings),
|
||||
}).Info("Added route")
|
||||
|
||||
// Note: With this architecture, we don't need to reload the server
|
||||
// The handler dynamically looks up routes on each request
|
||||
// Certificates will be obtained automatically when the domain is first accessed
|
||||
// Eagerly issue certificate in background
|
||||
go func(domain string) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
if err := p.certManager.IssueCertificate(ctx, domain); err != nil {
|
||||
log.Errorf("Failed to issue certificate: %v", err)
|
||||
}
|
||||
}(route.Domain)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -82,6 +91,9 @@ func (p *Proxy) RemoveRoute(domain string) error {
|
||||
// Remove route
|
||||
delete(p.routes, domain)
|
||||
|
||||
// Unregister domain from certificate manager
|
||||
p.certManager.RemoveDomain(domain)
|
||||
|
||||
log.Infof("Removed route for domain: %s", domain)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user