Skip to content

Commit

Permalink
Backport of #17138: Populate CRL data on backend startup (#17149)
Browse files Browse the repository at this point in the history
* Load existing CRLs on startup and after invalidate (#17138)

* Load existing CRLs on startup and after invalidate

* changelog

* Populate during renew calls also (#17143)

* Remove unused config fetch
  • Loading branch information
sgmiller committed Sep 15, 2022
1 parent b315d94 commit 33580bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/credential/cert/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend,
if err := b.Setup(ctx, conf); err != nil {
return nil, err
}
if err := b.populateCRLs(ctx, conf.StorageView); err != nil {
return nil, err
}
return b, nil
}

Expand Down
12 changes: 12 additions & 0 deletions builtin/credential/cert/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ func (b *backend) pathLoginAliasLookahead(ctx context.Context, req *logical.Requ
}

func (b *backend) pathLogin(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
if b.crls == nil {
if err := b.populateCRLs(ctx, req.Storage); err != nil {
return nil, err
}
}

var matched *ParsedCert
if verifyResp, resp, err := b.verifyCredentials(ctx, req, data); err != nil {
return nil, err
Expand Down Expand Up @@ -127,6 +133,12 @@ func (b *backend) pathLoginRenew(ctx context.Context, req *logical.Request, d *f
return nil, err
}

if b.crls == nil {
if err := b.populateCRLs(ctx, req.Storage); err != nil {
return nil, err
}
}

if !config.DisableBinding {
var matched *ParsedCert
if verifyResp, resp, err := b.verifyCredentials(ctx, req, d); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions changelog/17138.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
auth/cert: Vault does not initially load the CRLs in cert auth unless the read/write CRL endpoint is hit.
```

0 comments on commit 33580bb

Please sign in to comment.