|
|
@ -31,6 +31,16 @@ func NewService(fileService portainer.FileService, dataStore portainer.DataStore
|
|
|
|
|
|
|
|
|
|
|
|
// Init initializes the service
|
|
|
|
// Init initializes the service
|
|
|
|
func (service *Service) Init(host, certPath, keyPath string) error {
|
|
|
|
func (service *Service) Init(host, certPath, keyPath string) error {
|
|
|
|
|
|
|
|
pathSupplied := certPath != "" && keyPath != ""
|
|
|
|
|
|
|
|
if pathSupplied {
|
|
|
|
|
|
|
|
newCertPath, newKeyPath, err := service.fileService.CopySSLCertPair(certPath, keyPath)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return errors.Wrap(err, "failed copying supplied certs")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return service.cacheInfo(newCertPath, newKeyPath, false)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
settings, err := service.GetSSLSettings()
|
|
|
|
settings, err := service.GetSSLSettings()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return errors.Wrap(err, "failed fetching ssl settings")
|
|
|
|
return errors.Wrap(err, "failed fetching ssl settings")
|
|
|
@ -49,16 +59,6 @@ func (service *Service) Init(host, certPath, keyPath string) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pathSupplied := certPath != "" && keyPath != ""
|
|
|
|
|
|
|
|
if pathSupplied {
|
|
|
|
|
|
|
|
newCertPath, newKeyPath, err := service.fileService.CopySSLCertPair(certPath, keyPath)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return errors.Wrap(err, "failed copying supplied certs")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return service.cacheInfo(newCertPath, newKeyPath, false)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// path not supplied and certificates doesn't exist - generate self signed
|
|
|
|
// path not supplied and certificates doesn't exist - generate self signed
|
|
|
|
certPath, keyPath = service.fileService.GetDefaultSSLCertsPath()
|
|
|
|
certPath, keyPath = service.fileService.GetDefaultSSLCertsPath()
|
|
|
|
|
|
|
|
|
|
|
|