mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-27 05:31:40 +01:00
Fix logic around zero path length -- only restrict issuing intermediate CAs in this case
This commit is contained in:
parent
237285e822
commit
636fad0180
@ -483,9 +483,6 @@ func generateCreationBundle(b *backend,
|
||||
}
|
||||
|
||||
if signingBundle != nil {
|
||||
if signingBundle.Certificate.MaxPathLen == 0 {
|
||||
return nil, certutil.UserError{Err: "signing CA has a max path length of zero"}
|
||||
}
|
||||
creationBundle.URLs = signingBundle.URLs
|
||||
if role.MaxPathLength != nil {
|
||||
creationBundle.MaxPathLength = *role.MaxPathLength
|
||||
@ -493,8 +490,10 @@ func generateCreationBundle(b *backend,
|
||||
switch {
|
||||
case signingBundle.Certificate.MaxPathLen < 0:
|
||||
creationBundle.MaxPathLength = -1
|
||||
case signingBundle.Certificate.MaxPathLen == 0:
|
||||
return nil, certutil.UserError{Err: "signing CA has a max path length of zero"}
|
||||
case signingBundle.Certificate.MaxPathLen == 0 &&
|
||||
signingBundle.Certificate.MaxPathLenZero:
|
||||
// The signing function will ensure that we do not issue a CA cert
|
||||
creationBundle.MaxPathLength = 0
|
||||
default:
|
||||
// If this takes it to zero, we handle this case later if
|
||||
// necessary
|
||||
@ -847,6 +846,11 @@ func signCertificate(creationInfo *certCreationBundle,
|
||||
if creationInfo.IsCA {
|
||||
certTemplate.IsCA = true
|
||||
|
||||
if creationInfo.SigningBundle.Certificate.MaxPathLen == 0 &&
|
||||
creationInfo.SigningBundle.Certificate.MaxPathLenZero {
|
||||
return nil, certutil.UserError{Err: "signing certificate has a max path length of zero, and cannot issue further CA certificates"}
|
||||
}
|
||||
|
||||
certTemplate.MaxPathLen = creationInfo.MaxPathLength
|
||||
if certTemplate.MaxPathLen == 0 {
|
||||
certTemplate.MaxPathLenZero = true
|
||||
|
||||
@ -288,7 +288,7 @@ func (b *backend) pathCAGenerateRoot(
|
||||
}
|
||||
|
||||
if parsedBundle.Certificate.MaxPathLen == 0 {
|
||||
resp.AddWarning("Max path length of the generated certificate is zero")
|
||||
resp.AddWarning("Max path length of the generated certificate is zero. This certificate cannot be used to issue intermediate CA certificates.")
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
@ -444,7 +444,7 @@ func (b *backend) pathCASignIntermediate(
|
||||
}
|
||||
|
||||
if parsedBundle.Certificate.MaxPathLen == 0 {
|
||||
resp.AddWarning("Max path length of the signed certificate is zero")
|
||||
resp.AddWarning("Max path length of the signed certificate is zero. This certificate cannot be used to issue intermediate CA certificates.")
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user