Skip to content

Commit 53df9b0

Browse files
alisharif2samribeiro
authored andcommitted
Removing pathlen information in accordance with RFC5280 4.2.1.9 (google#78)
* Update entity.go According to https://tools.ietf.org/html/rfc5280 the pathlen information must be omitted if the CA boolean is false. In this case, since you never assert the CA to be true (hence default false) you must remove the pathlen information. * remove certMaxPathLen variable * certMaxPathLen needed to generate templateCA cert Previously I removed the MaxPathLen and MaxPathLenZero information from Template(), however, TemplateCA() assumes this information present when calling Template() thus I've re-added the certMaxPathLen variable and moved the addition of that pathlen information from Template() to TemplateCA() * remove pathlen from install,rotate,provision certs The certificates that were being installed on the devices via RPCs install and provision were using signer() func in gnoi_cert.go that took the CSR from the device. signer() used FromSigningRequest() to sign certs and thus was also adding pathlen information to the certificates that would be installed on the device.
1 parent 23a1392 commit 53df9b0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

utils/entity/entity.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ func FromSigningRequest(csr *x509.CertificateRequest) (*Entity, error) {
102102
DNSNames: csr.DNSNames,
103103
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
104104
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,
105-
MaxPathLen: certMaxPathLen,
106-
MaxPathLenZero: true,
107105
NotAfter: time.Now().Add(certExpiration),
108106
NotBefore: time.Now(),
109107
SignatureAlgorithm: csr.SignatureAlgorithm,
@@ -214,6 +212,8 @@ func TemplateCA(cn string) *x509.Certificate {
214212
ca := Template(cn)
215213
ca.KeyUsage = x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign | x509.KeyUsageCRLSign
216214
ca.IsCA = true
215+
ca.MaxPathLen = certMaxPathLen
216+
ca.MaxPathLenZero = true
217217
return ca
218218
}
219219

@@ -240,8 +240,6 @@ func Template(cn string) *x509.Certificate {
240240
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
241241
// IsCA,
242242
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,
243-
MaxPathLen: certMaxPathLen,
244-
MaxPathLenZero: true,
245243
NotAfter: time.Now().Add(24 * 365 * time.Hour),
246244
NotBefore: time.Now(),
247245
// PermittedDNSDomains,

0 commit comments

Comments
 (0)