TUN-9998: Don't need to read origin cert to determine if the endpoint is fedramp

This commit is contained in:
chungthuang 2025-11-04 13:46:47 -06:00 committed by João "Pisco" Fernandes
parent 1e907e99b5
commit 3e6d8ed216
2 changed files with 14 additions and 18 deletions

View File

@ -427,15 +427,16 @@ func StartServer(
return waitToShutdown(&wg, cancel, errC, graceShutdownC, 0, log) return waitToShutdown(&wg, cancel, errC, graceShutdownC, 0, log)
} }
if namedTunnel == nil {
return fmt.Errorf("namedTunnel is nil outside of DNS proxy stand-alone mode")
}
logTransport := logger.CreateTransportLoggerFromContext(c, logger.EnableTerminalLog) logTransport := logger.CreateTransportLoggerFromContext(c, logger.EnableTerminalLog)
observer := connection.NewObserver(log, logTransport) observer := connection.NewObserver(log, logTransport)
// Send Quick Tunnel URL to UI if applicable // Send Quick Tunnel URL to UI if applicable
var quickTunnelURL string quickTunnelURL := namedTunnel.QuickTunnelUrl
if namedTunnel != nil {
quickTunnelURL = namedTunnel.QuickTunnelUrl
}
if quickTunnelURL != "" { if quickTunnelURL != "" {
observer.SendURL(quickTunnelURL) observer.SendURL(quickTunnelURL)
} }
@ -459,14 +460,7 @@ func StartServer(
} }
} }
userCreds, err := credentials.Read(c.String(cfdflags.OriginCert), log) isFEDEndpoint := namedTunnel.Credentials.Endpoint == credentials.FedEndpoint
var isFEDEndpoint bool
if err != nil {
isFEDEndpoint = false
} else {
isFEDEndpoint = userCreds.IsFEDEndpoint()
}
var managementHostname string var managementHostname string
if isFEDEndpoint { if isFEDEndpoint {
managementHostname = credentials.FedRampHostname managementHostname = credentials.FedRampHostname

View File

@ -63,12 +63,14 @@ func (s searchByID) Path() (string, error) {
Str("originCertPath", originCertPath). Str("originCertPath", originCertPath).
Logger() Logger()
// Fallback to look for tunnel credentials in the origin cert directory if originCertPath != "" {
if originCertPath, err := credentials.FindOriginCert(originCertPath, &originCertLog); err == nil { // Look for tunnel credentials in the origin cert directory if the flag is provided
originCertDir := filepath.Dir(originCertPath) if originCertPath, err := credentials.FindOriginCert(originCertPath, &originCertLog); err == nil {
if filePath, err := tunnelFilePath(s.id, originCertDir); err == nil { originCertDir := filepath.Dir(originCertPath)
if s.fs.validFilePath(filePath) { if filePath, err := tunnelFilePath(s.id, originCertDir); err == nil {
return filePath, nil if s.fs.validFilePath(filePath) {
return filePath, nil
}
} }
} }
} }