mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Fix various trivial warnings from staticcheck in the PKI plugin (#16946)
* Fix up simple warnings in production code * Address warnings from static check in the PKI test classes
This commit is contained in:
@@ -361,7 +361,7 @@ func (b *backend) pathUpdateIssuer(ctx context.Context, req *logical.Request, da
|
||||
if newUsage != issuer.Usage {
|
||||
if issuer.Revoked && newUsage.HasUsage(IssuanceUsage) {
|
||||
// Forbid allowing cert signing on its usage.
|
||||
return logical.ErrorResponse(fmt.Sprintf("This issuer was revoked; unable to modify its usage to include certificate signing again. Reissue this certificate (preferably with a new key) and modify that entry instead.")), nil
|
||||
return logical.ErrorResponse("This issuer was revoked; unable to modify its usage to include certificate signing again. Reissue this certificate (preferably with a new key) and modify that entry instead."), nil
|
||||
}
|
||||
|
||||
// Ensure we deny adding CRL usage if the bits are missing from the
|
||||
@@ -371,7 +371,7 @@ func (b *backend) pathUpdateIssuer(ctx context.Context, req *logical.Request, da
|
||||
return nil, fmt.Errorf("unable to parse issuer's certificate: %v", err)
|
||||
}
|
||||
if (cert.KeyUsage&x509.KeyUsageCRLSign) == 0 && newUsage.HasUsage(CRLSigningUsage) {
|
||||
return logical.ErrorResponse(fmt.Sprintf("This issuer's underlying certificate lacks the CRLSign KeyUsage value; unable to set CRLSigningUsage on this issuer as a result.")), nil
|
||||
return logical.ErrorResponse("This issuer's underlying certificate lacks the CRLSign KeyUsage value; unable to set CRLSigningUsage on this issuer as a result."), nil
|
||||
}
|
||||
|
||||
issuer.Usage = newUsage
|
||||
@@ -576,7 +576,7 @@ func (b *backend) pathPatchIssuer(ctx context.Context, req *logical.Request, dat
|
||||
if newUsage != issuer.Usage {
|
||||
if issuer.Revoked && newUsage.HasUsage(IssuanceUsage) {
|
||||
// Forbid allowing cert signing on its usage.
|
||||
return logical.ErrorResponse(fmt.Sprintf("This issuer was revoked; unable to modify its usage to include certificate signing again. Reissue this certificate (preferably with a new key) and modify that entry instead.")), nil
|
||||
return logical.ErrorResponse("This issuer was revoked; unable to modify its usage to include certificate signing again. Reissue this certificate (preferably with a new key) and modify that entry instead."), nil
|
||||
}
|
||||
|
||||
cert, err := issuer.GetCertificate()
|
||||
@@ -584,7 +584,7 @@ func (b *backend) pathPatchIssuer(ctx context.Context, req *logical.Request, dat
|
||||
return nil, fmt.Errorf("unable to parse issuer's certificate: %v", err)
|
||||
}
|
||||
if (cert.KeyUsage&x509.KeyUsageCRLSign) == 0 && newUsage.HasUsage(CRLSigningUsage) {
|
||||
return logical.ErrorResponse(fmt.Sprintf("This issuer's underlying certificate lacks the CRLSign KeyUsage value; unable to set CRLSigningUsage on this issuer as a result.")), nil
|
||||
return logical.ErrorResponse("This issuer's underlying certificate lacks the CRLSign KeyUsage value; unable to set CRLSigningUsage on this issuer as a result."), nil
|
||||
}
|
||||
|
||||
issuer.Usage = newUsage
|
||||
|
||||
Reference in New Issue
Block a user