Skip to content

Commit

Permalink
Add critical bool arg to MarshalSubjectAltName to allow SANs to be cr…
Browse files Browse the repository at this point in the history
…itical (google#367)
  • Loading branch information
liamjm authored Mar 26, 2024
1 parent e6ab626 commit 5b37630
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions x509/x509ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ func forEachSAN(extension []byte, callback func(ext asn1.RawValue) error) error
return nil
}

// MarshalSubjectAltName converts a SubjectAltName struct into a pkix.Extension.
func MarshalSubjectAltName(san *SubjectAltName) (pkix.Extension, error) {
// MarshalSubjectAltName converts a SubjectAltName struct into a pkix.Extension,
// allowing callers to specify if the extension is critical.
func MarshalSubjectAltName(san *SubjectAltName, critical bool) (pkix.Extension, error) {
var generalNames []asn1.RawValue
for _, permID := range san.PermanentIdentifiers {
val, err := marshalOtherName(oidPermanentIdentifier, permID)
Expand All @@ -171,7 +172,8 @@ func MarshalSubjectAltName(san *SubjectAltName) (pkix.Extension, error) {
return pkix.Extension{}, err
}
return pkix.Extension{
Id: oid.SubjectAltName,
Value: val,
Id: oid.SubjectAltName,
Critical: critical,
Value: val,
}, nil
}

0 comments on commit 5b37630

Please sign in to comment.