private static Asn1Sequence FromCertificate( X509Certificate certificate) { try { GeneralName genName = new GeneralName( PrincipalUtilities.GetIssuerX509Principal(certificate)); if (certificate.Version == 3) { Asn1OctetString ext = certificate.GetExtensionValue(X509Extensions.SubjectKeyIdentifier); if (ext != null) { Asn1OctetString str = (Asn1OctetString)X509ExtensionUtilities.FromExtensionValue(ext); return((Asn1Sequence) new AuthorityKeyIdentifier( str.GetOctets(), new GeneralNames(genName), certificate.SerialNumber).ToAsn1Object()); } } SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo( certificate.GetPublicKey()); return((Asn1Sequence) new AuthorityKeyIdentifier( info, new GeneralNames(genName), certificate.SerialNumber).ToAsn1Object()); } catch (Exception e) { throw new CertificateParsingException("Exception extracting certificate details", e); } }
/** * Constructor which will take the byte[] returned from getExtensionValue() * * @param encodedValue a DER octet encoded string with the extension structure in it. * @throws IOException on parsing errors. */ public SubjectKeyIdentifierStructure( Asn1OctetString encodedValue) : base((Asn1OctetString)X509ExtensionUtilities.FromExtensionValue(encodedValue)) { }
/** * Constructor which will take the byte[] returned from getExtensionValue() * * @param encodedValue a DER octet encoded string with the extension structure in it. * @throws IOException on parsing errors. */ // TODO Add a functional constructor from byte[]? public AuthorityKeyIdentifierStructure( Asn1OctetString encodedValue) : base((Asn1Sequence)X509ExtensionUtilities.FromExtensionValue(encodedValue)) { }