mirror of
https://github.com/minio/minio.git
synced 2025-04-23 20:05:55 -04:00
pkg/certs: On windows watch for directory changes to load certs (#6128)
This PR fixes an issue when configuring Minio TLS on windows
This commit is contained in:
parent
c62813c887
commit
0ef0d7e685
@ -18,6 +18,7 @@ package certs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/rjeczalik/notify"
|
"github.com/rjeczalik/notify"
|
||||||
@ -74,11 +75,14 @@ func (c *Certs) watch() (err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err = notify.Watch(c.certFile, c.e, eventWrite...); err != nil {
|
// Windows doesn't allow for watching file changes but instead allows
|
||||||
|
// for directory changes only, while we can still watch for changes
|
||||||
|
// on files on other platforms. Watch parent directory on all platforms
|
||||||
|
// for simplicity.
|
||||||
|
if err = notify.Watch(filepath.Dir(c.certFile), c.e, eventWrite...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err = notify.Watch(filepath.Dir(c.keyFile), c.e, eventWrite...); err != nil {
|
||||||
if err = notify.Watch(c.keyFile, c.e, eventWrite...); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.Lock()
|
c.Lock()
|
||||||
@ -93,16 +97,21 @@ func (c *Certs) watch() (err error) {
|
|||||||
|
|
||||||
func (c *Certs) run() {
|
func (c *Certs) run() {
|
||||||
for event := range c.e {
|
for event := range c.e {
|
||||||
|
base := filepath.Base(event.Path())
|
||||||
if isWriteEvent(event.Event()) {
|
if isWriteEvent(event.Event()) {
|
||||||
cert, err := c.loadCert(c.certFile, c.keyFile)
|
certChanged := base == filepath.Base(c.certFile)
|
||||||
if err != nil {
|
keyChanged := base == filepath.Base(c.keyFile)
|
||||||
// ignore the error continue to use
|
if certChanged || keyChanged {
|
||||||
// old certificates.
|
cert, err := c.loadCert(c.certFile, c.keyFile)
|
||||||
continue
|
if err != nil {
|
||||||
|
// ignore the error continue to use
|
||||||
|
// old certificates.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
c.Lock()
|
||||||
|
c.cert = cert
|
||||||
|
c.Unlock()
|
||||||
}
|
}
|
||||||
c.Lock()
|
|
||||||
c.cert = cert
|
|
||||||
c.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user