mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Load TLS config files from config path before stash home (#1678)
* Load tls files from config or home directory * Update README * Require both ssl files if either present
This commit is contained in:
@@ -157,18 +157,11 @@ func (e MissingConfigError) Error() string {
|
||||
return fmt.Sprintf("missing the following mandatory settings: %s", strings.Join(e.missingFields, ", "))
|
||||
}
|
||||
|
||||
func HasTLSConfig() bool {
|
||||
ret, _ := utils.FileExists(paths.GetSSLCert())
|
||||
if ret {
|
||||
ret, _ = utils.FileExists(paths.GetSSLKey())
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type Instance struct {
|
||||
cpuProfilePath string
|
||||
isNewSystem bool
|
||||
certFile string
|
||||
keyFile string
|
||||
sync.RWMutex
|
||||
//deadlock.RWMutex // for deadlock testing/issues
|
||||
}
|
||||
@@ -192,6 +185,26 @@ func (i *Instance) SetConfigFile(fn string) {
|
||||
viper.SetConfigFile(fn)
|
||||
}
|
||||
|
||||
func (i *Instance) InitTLS() {
|
||||
configDirectory := i.GetConfigPath()
|
||||
tlsPaths := []string{
|
||||
configDirectory,
|
||||
paths.GetStashHomeDirectory(),
|
||||
}
|
||||
|
||||
i.certFile = utils.FindInPaths(tlsPaths, "stash.crt")
|
||||
i.keyFile = utils.FindInPaths(tlsPaths, "stash.key")
|
||||
}
|
||||
|
||||
func (i *Instance) GetTLSFiles() (certFile, keyFile string) {
|
||||
return i.certFile, i.keyFile
|
||||
}
|
||||
|
||||
func (i *Instance) HasTLSConfig() bool {
|
||||
certFile, keyFile := i.GetTLSFiles()
|
||||
return certFile != "" && keyFile != ""
|
||||
}
|
||||
|
||||
// GetCPUProfilePath returns the path to the CPU profile file to output
|
||||
// profiling info to. This is set only via a commandline flag. Returns an
|
||||
// empty string if not set.
|
||||
|
||||
Reference in New Issue
Block a user