Fix setter of basic constraints.

This commit is contained in:
Mariano Cano 2020-07-08 16:29:33 -07:00
parent 068bafe5a3
commit 0847af16cb

View file

@ -293,9 +293,17 @@ type BasicConstraints struct {
// Set sets the basic constraints to the given certificate.
func (b BasicConstraints) Set(c *x509.Certificate) {
c.IsCA = b.IsCA
c.MaxPathLen = b.MaxPathLen
if c.MaxPathLen < 0 {
c.MaxPathLen = -1
if c.IsCA {
c.BasicConstraintsValid = true
switch {
case b.MaxPathLen == 0:
c.MaxPathLen = b.MaxPathLen
c.MaxPathLenZero = true
case b.MaxPathLen < 0:
c.MaxPathLen = -1
default:
c.MaxPathLen = b.MaxPathLen
}
}
}