forked from TrueCloudLab/certificates
Fix setter of basic constraints.
This commit is contained in:
parent
068bafe5a3
commit
0847af16cb
1 changed files with 11 additions and 3 deletions
|
@ -293,9 +293,17 @@ type BasicConstraints struct {
|
||||||
// Set sets the basic constraints to the given certificate.
|
// Set sets the basic constraints to the given certificate.
|
||||||
func (b BasicConstraints) Set(c *x509.Certificate) {
|
func (b BasicConstraints) Set(c *x509.Certificate) {
|
||||||
c.IsCA = b.IsCA
|
c.IsCA = b.IsCA
|
||||||
c.MaxPathLen = b.MaxPathLen
|
if c.IsCA {
|
||||||
if c.MaxPathLen < 0 {
|
c.BasicConstraintsValid = true
|
||||||
c.MaxPathLen = -1
|
switch {
|
||||||
|
case b.MaxPathLen == 0:
|
||||||
|
c.MaxPathLen = b.MaxPathLen
|
||||||
|
c.MaxPathLenZero = true
|
||||||
|
case b.MaxPathLen < 0:
|
||||||
|
c.MaxPathLen = -1
|
||||||
|
default:
|
||||||
|
c.MaxPathLen = b.MaxPathLen
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue