File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ package manager
18
18
19
19
import (
20
20
"context"
21
+ "crypto/x509"
22
+ "encoding/pem"
21
23
"errors"
22
24
"fmt"
23
25
"math"
@@ -402,6 +404,18 @@ func (m *Manager) issue(ctx context.Context, volumeID string) error {
402
404
return fmt .Errorf ("waiting for request: %w" , err )
403
405
}
404
406
407
+ // Default the renewal time to be halfway through the certificate's duration.
408
+ // The implementation's writeKeypair function may override this value before
409
+ // writing to the storage layer.
410
+ block , _ := pem .Decode (req .Status .Certificate )
411
+ crt , err := x509 .ParseCertificate (block .Bytes )
412
+ if err != nil {
413
+ return fmt .Errorf ("parsing issued certificate: %w" , err )
414
+ }
415
+ duration := crt .NotAfter .Sub (crt .NotBefore )
416
+ midpoint := crt .NotBefore .Add (duration / 2 )
417
+ meta .NextIssuanceTime = & midpoint
418
+
405
419
if err := m .writeKeypair (meta , key , req .Status .Certificate , req .Status .CA ); err != nil {
406
420
return fmt .Errorf ("writing keypair: %w" , err )
407
421
}
You can’t perform that action at this time.
0 commit comments