@@ -416,6 +416,26 @@ func parseSANExtension(der cryptobyte.String) (dnsNames, emailAddresses []string
416
416
return
417
417
}
418
418
419
+ func parseAuthorityKeyIdentifier (e pkix.Extension ) ([]byte , error ) {
420
+ // RFC 5280, Section 4.2.1.1
421
+ if e .Critical {
422
+ // Conforming CAs MUST mark this extension as non-critical
423
+ return nil , errors .New ("x509: authority key identifier incorrectly marked critical" )
424
+ }
425
+ val := cryptobyte .String (e .Value )
426
+ var akid cryptobyte.String
427
+ if ! val .ReadASN1 (& akid , cryptobyte_asn1 .SEQUENCE ) {
428
+ return nil , errors .New ("x509: invalid authority key identifier" )
429
+ }
430
+ if akid .PeekASN1Tag (cryptobyte_asn1 .Tag (0 ).ContextSpecific ()) {
431
+ if ! akid .ReadASN1 (& akid , cryptobyte_asn1 .Tag (0 ).ContextSpecific ()) {
432
+ return nil , errors .New ("x509: invalid authority key identifier" )
433
+ }
434
+ return akid , nil
435
+ }
436
+ return nil , nil
437
+ }
438
+
419
439
func parseExtKeyUsageExtension (der cryptobyte.String ) ([]ExtKeyUsage , []asn1.ObjectIdentifier , error ) {
420
440
var extKeyUsages []ExtKeyUsage
421
441
var unknownUsages []asn1.ObjectIdentifier
@@ -723,21 +743,9 @@ func processExtensions(out *Certificate) error {
723
743
}
724
744
725
745
case 35 :
726
- // RFC 5280, 4.2.1.1
727
- if e .Critical {
728
- // Conforming CAs MUST mark this extension as non-critical
729
- return errors .New ("x509: authority key identifier incorrectly marked critical" )
730
- }
731
- val := cryptobyte .String (e .Value )
732
- var akid cryptobyte.String
733
- if ! val .ReadASN1 (& akid , cryptobyte_asn1 .SEQUENCE ) {
734
- return errors .New ("x509: invalid authority key identifier" )
735
- }
736
- if akid .PeekASN1Tag (cryptobyte_asn1 .Tag (0 ).ContextSpecific ()) {
737
- if ! akid .ReadASN1 (& akid , cryptobyte_asn1 .Tag (0 ).ContextSpecific ()) {
738
- return errors .New ("x509: invalid authority key identifier" )
739
- }
740
- out .AuthorityKeyId = akid
746
+ out .AuthorityKeyId , err = parseAuthorityKeyIdentifier (e )
747
+ if err != nil {
748
+ return err
741
749
}
742
750
case 37 :
743
751
out .ExtKeyUsage , out .UnknownExtKeyUsage , err = parseExtKeyUsageExtension (e .Value )
@@ -1226,7 +1234,10 @@ func ParseRevocationList(der []byte) (*RevocationList, error) {
1226
1234
return nil , err
1227
1235
}
1228
1236
if ext .Id .Equal (oidExtensionAuthorityKeyId ) {
1229
- rl .AuthorityKeyId = ext .Value
1237
+ rl .AuthorityKeyId , err = parseAuthorityKeyIdentifier (ext )
1238
+ if err != nil {
1239
+ return nil , err
1240
+ }
1230
1241
} else if ext .Id .Equal (oidExtensionCRLNumber ) {
1231
1242
value := cryptobyte .String (ext .Value )
1232
1243
rl .Number = new (big.Int )
0 commit comments