Skip to content

Commit

Permalink
Default crl expiry
Browse files Browse the repository at this point in the history
Ref: #17642
  • Loading branch information
JNProtzman committed Oct 27, 2022
1 parent 0423ffb commit 312bf6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 6 additions & 8 deletions builtin/logical/pki/crl_util.go
Expand Up @@ -1248,11 +1248,6 @@ func augmentWithRevokedIssuers(issuerIDEntryMap map[issuerID]*issuerEntry, issue
func buildCRL(sc *storageContext, crlInfo *crlConfig, forceNew bool, thisIssuerId issuerID, revoked []pkix.RevokedCertificate, identifier crlID, crlNumber int64, isDelta bool, lastCompleteNumber int64) (*time.Time, error) {
var revokedCerts []pkix.RevokedCertificate

crlLifetime, err := time.ParseDuration(crlInfo.Expiry)
if err != nil {
return nil, errutil.InternalError{Err: fmt.Sprintf("error parsing CRL duration of %s", crlInfo.Expiry)}
}

if crlInfo.Disable {
if !forceNew {
// In the event of a disabled CRL, we'll have the next time set
Expand All @@ -1266,12 +1261,15 @@ func buildCRL(sc *storageContext, crlInfo *crlConfig, forceNew bool, thisIssuerI
// forceNew option). In previous versions of Vault (1.10 series and
// earlier), we'd have queried the certs below, whereas we now have
// an assignment from a pre-queried list.
goto WRITE
} else {
revokedCerts = revoked
}

revokedCerts = revoked
crlLifetime, err := time.ParseDuration(crlInfo.Expiry)
if err != nil {
return nil, errutil.InternalError{Err: fmt.Sprintf("error parsing CRL duration of %q", crlInfo.Expiry)}
}

WRITE:
signingBundle, caErr := sc.fetchCAInfoByIssuerId(thisIssuerId, CRLSigningUsage)
if caErr != nil {
switch caErr.(type) {
Expand Down
6 changes: 6 additions & 0 deletions builtin/logical/pki/storage.go
Expand Up @@ -1174,6 +1174,12 @@ func (sc *storageContext) getRevocationConfig() (*crlConfig, error) {
result.Version = 1
}

// Depending on client version, it's possible that the expiry is unset.
// This sets the default value to prevent issues in downstream code.
if result.Expiry == "" {
result.Expiry = defaultCrlConfig.Expiry
}

return &result, nil
}

Expand Down

0 comments on commit 312bf6b

Please sign in to comment.