Skip to content

Commit 0379fdd

Browse files
authored
Feat: remove non-used certPEM keyPEM (#52)
* fix: non-used ones * feat: todo with details
1 parent f3fd618 commit 0379fdd

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

service/cert-reloader.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ type LogFn func(format string, args ...interface{})
4040
// CertReloader reloads the (key, cert) pair from the filesystem when
4141
// the cert file is updated.
4242
type CertReloader struct {
43-
l sync.RWMutex
44-
certPath string
45-
keyPath string
46-
caPath string
47-
cert *tls.Certificate
48-
certPEM []byte
49-
keyPEM []byte
43+
l sync.RWMutex
44+
certPath string
45+
keyPath string
46+
caPath string
47+
cert *tls.Certificate
48+
// certPEM []byte
49+
// keyPEM []byte
5050
caPool *x509.CertPool // This is optional and can be nil
5151
mtime time.Time
5252
pollInterval time.Duration
@@ -126,19 +126,22 @@ func (w *CertReloader) loadLocalCertAndKey() error {
126126
if err != nil {
127127
return errors.Wrap(err, fmt.Sprintf("unable to load cert from %s,%s", w.certPath, w.keyPath))
128128
}
129-
certPEM, err := os.ReadFile(w.certPath)
130-
if err != nil {
131-
return errors.Wrap(err, fmt.Sprintf("unable to load cert from %s", w.certPath))
132-
}
133-
keyPEM, err := os.ReadFile(w.keyPath)
134-
if err != nil {
135-
return errors.Wrap(err, fmt.Sprintf("unable to load key from %s", w.keyPath))
136-
}
129+
130+
// TODO: The following code potentially has the bug as the following issue describes:
131+
// TODO: https://github.com/AthenZ/k8s-athenz-sia/issues/177
132+
// certPEM, err := os.ReadFile(w.certPath)
133+
// if err != nil {
134+
// return errors.Wrap(err, fmt.Sprintf("unable to load cert from %s", w.certPath))
135+
// }
136+
// keyPEM, err := os.ReadFile(w.keyPath)
137+
// if err != nil {
138+
// return errors.Wrap(err, fmt.Sprintf("unable to load key from %s", w.keyPath))
139+
// }
137140

138141
w.l.Lock()
139142
w.cert = &cert
140-
w.certPEM = certPEM
141-
w.keyPEM = keyPEM
143+
// w.certPEM = certPEM
144+
// w.keyPEM = keyPEM
142145
w.mtime = st.ModTime()
143146
w.l.Unlock()
144147

0 commit comments

Comments
 (0)