-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Proposal: X509AuthorityKeyIdentifierExtension #50488
Comments
Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks Issue DetailsBackground and MotivationThe .NET API includes the The SKI is usually used together with the Authority Key Identifier (AKI) so you can identify the public key to be used to verify the signature on a certificate. There's no built-in class to read the AKI. Proposed API+ public class X509AuthorityKeyIdentifierExtension: System.Security.Cryptography.X509Certificates.X509Extension
+ {
+ public X509AuthorityKeyIdentifierExtension() { }
+ public X509AuthorityKeyIdentifierExtension(System.ReadOnlySpan<byte> authorityKeyIdentifier, bool critical) { }
+ public X509AuthorityKeyIdentifierExtension(System.Security.Cryptography.AsnEncodedData encodedAuthorityKeyIdentifier, bool critical) { }
+ } Usage ExamplesCreate a new certificate X509Certificate2 signingCertificate;
var issuerSubjectKey = signingCertificate.Extensions.OfType<X509SubjectKeyIdentifierExtension>().Single().RawData;
CertificateRequest hostRequest = new CertificateRequest(...);
request.CertificateExtensions.Add(new X509SubjectKeyIdentifierExtension(issuerSubjectKey.Slice(2))); Alternative DesignsThe API proposal follows the API shape of the other RisksNew API, so risk should be low.
|
I think we typically have public X509AuthorityKeyIdentifierExtension(byte[] authorityKeyIdentifier, bool critical);
public X509AuthorityKeyIdentifierExtension(System.Security.Cryptography.X509Certificates.PublicKey key, bool critical); |
var issuerSubjectKey = signingCertificate.Extensions.OfType<X509SubjectKeyIdentifierExtension>().Single().RawData;
request.CertificateExtensions.Add(new X509SubjectKeyIdentifierExtension(issuerSubjectKey.Slice(2))); Needing to do Slice(2) seems like the API is missing something 😄. It's assuming (a) that a So it definitely needs some extra properties. And then probably needs more constructors:
Though issuer is a And, even though we haven't done it on the existing extension types, the critical parameter should be defaulted... in this case, to false. |
I don't think so; there are multiple ways to derive a key identifier from a public key. So you pass a |
Well, my reading of the RFC (but I'm known to be wrong at times 😄) is that section 4.2.1.1 says that it's either the key identifier or the issuer name and serial number. So that would leave two overloads. Regarding So something like: + public X509AuthorityKeyIdentifierExtension(byte[] keyIdentifier, bool critical = false);
+ public X509AuthorityKeyIdentifierExtension(X500DistringuishedName issuerName, int serialNumber, bool critical = false); It could be helpful if |
I can see that reading, but I feel like I've seen some Issuing CA certs that had both, and OpenSSL's chain processing code definitely handles both. The X.509 standard says it's ok (emphasis mine):
X.509 also says (in 18.3.2.2 Use of authority key identifier):
I don't think I've seen authorityKeyIdentifier used as a fetch source... or a cert that populated that data there... but that's what the standard says. |
if this helps, here is a MIT licensed implementation based on the ASN.1 library. |
There were two issues for this, apparently, and I've made an API proposal out of the older one (#24931). Closing this one in favor of that one. |
Background and Motivation
The .NET API includes the
X509SubjectKeyIdentifierExtension
which allows you to read the subject key identifier extension of a certificate.The SKI is usually used together with the Authority Key Identifier (AKI) so you can identify the public key to be used to verify the signature on a certificate.
There's no built-in class to read the AKI.
Proposed API
Usage Examples
Create a new certificate
Alternative Designs
The API proposal follows the API shape of the other
X509*Extension
classes.Risks
New API, so risk should be low.
The text was updated successfully, but these errors were encountered: