Skip to content

Commit 6e632f9

Browse files
authored
Only generate a certificate if an existing in memory certificate isn't already set (#78)
* Only generate a certificate if an existing in memory certificate isn't set Signed-off-by: David Negstad <[email protected]> * Add a boolean to indicate whether GeneratedCert already has a value Signed-off-by: David Negstad <[email protected]> --------- Signed-off-by: David Negstad <[email protected]>
1 parent 3f611d9 commit 6e632f9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/server/options/serving.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ type GeneratableKeyCert struct {
107107
// GeneratedCert holds an in-memory generated certificate if CertFile/KeyFile aren't explicitly set, and CertDirectory/PairName are not set.
108108
GeneratedCert dynamiccertificates.CertKeyContentProvider
109109

110+
// Indicates whether GeneratedCert already has a pre-generated value (in which case it should not be regenerated).
111+
PregeneratedCert bool
112+
110113
// FixtureDirectory is a directory that contains test fixture used to avoid regeneration of certs during tests.
111114
// The format is:
112115
// <host>_<ip>-<ip>_<alternateDNS>-<alternateDNS>.crt
@@ -288,6 +291,9 @@ func (s *SecureServingOptions) MaybeDefaultWithSelfSignedCerts(publicAddress str
288291
if s == nil || (s.BindPort == 0 && s.Listener == nil) {
289292
return nil
290293
}
294+
if s.ServerCert.PregeneratedCert {
295+
return nil
296+
}
291297
keyCert := &s.ServerCert.CertKey
292298
if len(keyCert.CertFile) != 0 || len(keyCert.KeyFile) != 0 {
293299
return nil

0 commit comments

Comments
 (0)