add cfg file setting to skip SSL verification

This commit is contained in:
Drew Weymouth
2024-07-28 08:22:07 -07:00
parent c3d3cf92a7
commit 1f8e8d2936
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -46,6 +46,7 @@ type AppConfig struct {
DefaultPlaylistID string DefaultPlaylistID string
ShowTrackChangeNotification bool ShowTrackChangeNotification bool
EnableLrcLib bool EnableLrcLib bool
SkipSSLVerify bool
// Experimental - may be removed in future // Experimental - may be removed in future
FontNormalTTF string FontNormalTTF string
@@ -170,6 +171,7 @@ func DefaultConfig(appVersionTag string) *Config {
SaveQueueToServer: false, SaveQueueToServer: false,
ShowTrackChangeNotification: false, ShowTrackChangeNotification: false,
EnableLrcLib: true, EnableLrcLib: true,
SkipSSLVerify: false,
}, },
AlbumPage: AlbumPageConfig{ AlbumPage: AlbumPageConfig{
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"}, TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"},
+13
View File
@@ -2,6 +2,7 @@ package backend
import ( import (
"context" "context"
"crypto/tls"
"errors" "errors"
"log" "log"
"net/http" "net/http"
@@ -176,6 +177,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
log.Printf("error creating Jellyfin client: %s", err.Error()) log.Printf("error creating Jellyfin client: %s", err.Error())
return nil, err return nil, err
} }
s.checkSetInsecureSkipVerify(client.HTTPClient)
cli = &jellyfinMP.JellyfinServer{ cli = &jellyfinMP.JellyfinServer{
Client: *client, Client: *client,
} }
@@ -186,6 +188,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
log.Printf("error creating Jellyfin alternative client: %s", err.Error()) log.Printf("error creating Jellyfin alternative client: %s", err.Error())
return nil, err return nil, err
} }
s.checkSetInsecureSkipVerify(altClient.HTTPClient)
altCli = &jellyfinMP.JellyfinServer{ altCli = &jellyfinMP.JellyfinServer{
Client: *altClient, Client: *altClient,
} }
@@ -200,6 +203,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
ClientName: res.AppName, ClientName: res.AppName,
}, },
} }
s.checkSetInsecureSkipVerify(cli.(*subsonicMP.SubsonicServer).Client.Client)
altCli = &subsonicMP.SubsonicServer{ altCli = &subsonicMP.SubsonicServer{
Client: subsonic.Client{ Client: subsonic.Client{
Client: &http.Client{Timeout: 10 * time.Second}, Client: &http.Client{Timeout: 10 * time.Second},
@@ -209,6 +213,7 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
ClientName: res.AppName, ClientName: res.AppName,
}, },
} }
s.checkSetInsecureSkipVerify(altCli.(*subsonicMP.SubsonicServer).Client.Client)
} }
var authError error var authError error
pingChan := make(chan bool, 2) // false for primary hostname, true for alternate pingChan := make(chan bool, 2) // false for primary hostname, true for alternate
@@ -238,3 +243,11 @@ func (s *ServerManager) connect(connection ServerConnection, password string) (m
return cli, authError return cli, authError
} }
} }
func (s *ServerManager) checkSetInsecureSkipVerify(cli *http.Client) {
if s.config.Application.SkipSSLVerify {
cli.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
}
}