1
0
mirror of https://github.com/golang/go synced 2024-11-24 10:50:13 -07:00

crypto/x509: return err ans1.Marshal gives an error

Fixes #50663
This commit is contained in:
cuiweixie 2022-01-18 16:12:20 +08:00
parent eab9a77a60
commit 57ff5ddfe3

View File

@ -1269,10 +1269,7 @@ func marshalKeyUsage(ku KeyUsage) (pkix.Extension, error) {
bitString := a[:l] bitString := a[:l]
var err error var err error
ext.Value, err = asn1.Marshal(asn1.BitString{Bytes: bitString, BitLength: asn1BitLength(bitString)}) ext.Value, err = asn1.Marshal(asn1.BitString{Bytes: bitString, BitLength: asn1BitLength(bitString)})
if err != nil { return ext, err
return ext, err
}
return ext, nil
} }
func marshalExtKeyUsage(extUsages []ExtKeyUsage, unknownUsages []asn1.ObjectIdentifier) (pkix.Extension, error) { func marshalExtKeyUsage(extUsages []ExtKeyUsage, unknownUsages []asn1.ObjectIdentifier) (pkix.Extension, error) {
@ -1291,10 +1288,7 @@ func marshalExtKeyUsage(extUsages []ExtKeyUsage, unknownUsages []asn1.ObjectIden
var err error var err error
ext.Value, err = asn1.Marshal(oids) ext.Value, err = asn1.Marshal(oids)
if err != nil { return ext, err
return ext, err
}
return ext, nil
} }
func marshalBasicConstraints(isCA bool, maxPathLen int, maxPathLenZero bool) (pkix.Extension, error) { func marshalBasicConstraints(isCA bool, maxPathLen int, maxPathLenZero bool) (pkix.Extension, error) {
@ -1307,10 +1301,7 @@ func marshalBasicConstraints(isCA bool, maxPathLen int, maxPathLenZero bool) (pk
} }
var err error var err error
ext.Value, err = asn1.Marshal(basicConstraints{isCA, maxPathLen}) ext.Value, err = asn1.Marshal(basicConstraints{isCA, maxPathLen})
if err != nil { return ext, err
return ext, nil
}
return ext, nil
} }
func marshalCertificatePolicies(policyIdentifiers []asn1.ObjectIdentifier) (pkix.Extension, error) { func marshalCertificatePolicies(policyIdentifiers []asn1.ObjectIdentifier) (pkix.Extension, error) {
@ -1321,10 +1312,7 @@ func marshalCertificatePolicies(policyIdentifiers []asn1.ObjectIdentifier) (pkix
} }
var err error var err error
ext.Value, err = asn1.Marshal(policies) ext.Value, err = asn1.Marshal(policies)
if err != nil { return ext, err
return ext, err
}
return ext, nil
} }
func buildCSRExtensions(template *CertificateRequest) ([]pkix.Extension, error) { func buildCSRExtensions(template *CertificateRequest) ([]pkix.Extension, error) {