Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ZBCccc committed Oct 9, 2024
1 parent 0142839 commit 2fa2bc3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion crypto/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type GMDoubleCertKey struct {
EncKeyFile string
}

// X509_Version represents a version on an x509 certificate.
// X509_Version represents a version on a x509 certificate.
type X509_Version int

// Specify constants for x509 versions because the standard states that they
Expand Down Expand Up @@ -362,11 +362,24 @@ func validateExtensionInput(nid NID, value string) error {
// AddExtensions Wraps AddExtension using a map of NID to text extension.
// Will return without finishing if it encounters an error.
func (c *Certificate) AddExtensions(extensions map[NID]string) error {
targetNid := NID_authority_key_identifier
found := false
for nid, value := range extensions {
if nid == NID_authority_key_identifier {
found = true
continue
}
if err := c.AddExtension(nid, value); err != nil {
return err
}
}

// NID_authority_key_identifier depends on subject key ID, needs to be added last
if found {
if err := c.AddExtension(targetNid, extensions[targetNid]); err != nil {
return err
}
}
return nil
}

Expand Down

0 comments on commit 2fa2bc3

Please sign in to comment.