Browse Source

fix: Fail fast when TLS client creation fails

If TLS is enabled (https.client.enabled=true) but misconfigured,
fail immediately with glog.Fatalf rather than silently falling back
to plain HTTP. This prevents confusing runtime errors when the filer
only accepts HTTPS connections.
pull/7633/head
chrislu 5 days ago
parent
commit
210c2cbc31
  1. 10
      weed/admin/handlers/file_browser_handlers.go

10
weed/admin/handlers/file_browser_handlers.go

@ -31,15 +31,11 @@ type FileBrowserHandlers struct {
func NewFileBrowserHandlers(adminServer *dash.AdminServer) *FileBrowserHandlers {
// Create HTTP client with TLS support from https.client configuration
// The client is created without a timeout - each operation will set its own timeout
// If TLS is enabled but misconfigured, fail fast to alert the operator immediately
// rather than silently falling back to HTTP and causing confusing runtime errors
httpClient, err := client.NewHttpClient(client.Client)
if err != nil {
glog.Warningf("Failed to create HTTPS client for file browser, falling back to plain HTTP: %v", err)
// Create a fallback client without TLS, properly wiring the transport
transport := &http.Transport{}
httpClient = &client.HTTPClient{
Client: &http.Client{Transport: transport},
Transport: transport,
}
glog.Fatalf("Failed to create HTTPS client for file browser: %v", err)
}
return &FileBrowserHandlers{

Loading…
Cancel
Save