File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -279,10 +279,23 @@ static internal X509Certificate2 CreateCertificate(
279279 {
280280 // RFC 5280 section 4.2.1.2
281281 var subjectKeyIdentifier = new X509SubjectKeyIdentifierExtension ( request . PublicKey , X509SubjectKeyIdentifierHashAlgorithm . Sha256 , critical : false ) ;
282- // RFC 5280 section 4.2.1.1
283- var authorityKeyIdentifier = X509AuthorityKeyIdentifierExtension . CreateFromSubjectKeyIdentifier ( subjectKeyIdentifier ) ;
284-
285282 request . CertificateExtensions . Add ( subjectKeyIdentifier ) ;
283+
284+ // RFC 5280 section 4.2.1.1 - AKI must point to issuer's SKI, not self
285+ X509AuthorityKeyIdentifierExtension authorityKeyIdentifier ;
286+ if ( issuerCert != null )
287+ {
288+ // For CA-signed certs: AKI = issuer's SKI
289+ var issuerSki = issuerCert . Extensions . OfType < X509SubjectKeyIdentifierExtension > ( ) . FirstOrDefault ( ) ;
290+ authorityKeyIdentifier = issuerSki != null
291+ ? X509AuthorityKeyIdentifierExtension . CreateFromSubjectKeyIdentifier ( issuerSki )
292+ : X509AuthorityKeyIdentifierExtension . CreateFromSubjectKeyIdentifier ( subjectKeyIdentifier ) ;
293+ }
294+ else
295+ {
296+ // For self-signed: AKI = own SKI
297+ authorityKeyIdentifier = X509AuthorityKeyIdentifierExtension . CreateFromSubjectKeyIdentifier ( subjectKeyIdentifier ) ;
298+ }
286299 request . CertificateExtensions . Add ( authorityKeyIdentifier ) ;
287300 }
288301
You can’t perform that action at this time.
0 commit comments