Describe the type of ASN.1 data.
public static string Type( string fileOrPEMString )
Public Shared Function Type ( fileOrPEMString As String ) As String
The output is a string describing the most likely type of the ASN.1-formatted data, or an empty string ("") if the type cannot be determined. The following types are detected:
| Output string value | ASN.1 object type | Reference |
|---|---|---|
| EC PRIVATE KEY | ECPrivateKey | [RFC5915] |
| OCSP REQUEST | OCSPRequest | [RFC6960] |
| OCSP RESPONSE | OCSPResponse | [RFC6960] |
| PKCS1 RSA PRIVATE KEY | RSAPrivateKey | [RFC3447] |
| PKCS1 RSA PUBLIC KEY | RSAPublicKey | [RFC3447] |
| PKCS10 CERTIFICATE REQUEST | CertificationRequest | [RFC2986] |
| PKCS12 PFX | PFX | [RFC7292] |
| PKCS7 CERTIFICATE CHAIN | ContentInfo | [RFC5652] |
| PKCS7/CMS COMPRESSED DATA | ContentInfo | [RFC3274] |
| PKCS7/CMS DATA | ContentInfo | [RFC5652] |
| PKCS7/CMS ENVELOPED DATA | ContentInfo | [RFC5652] |
| CMS AUTH ENVELOPED DATA | ContentInfo | [RFC5083] |
| PKCS7/CMS SIGNED DATA | ContentInfo | [RFC5652] |
| PKCS8 ENCRYPTED PRIVATE KEY | EncryptedPrivateKeyInfo | [RFC5208][RFC5958] |
| PKCS8 PRIVATE KEY INFO | PrivateKeyInfo | [RFC5208][RFC5958] |
| PKCS8 ONE ASYMMETRIC KEY | OneAsymmetricKey | [RFC5958] |
| PUBLIC KEY INFO | SubjectPublicKeyInfo | [RFC3279][RFC5480] |
| X509 CERTIFICATE | Certificate | [RFC5280] |
| X509 CRL | CertificateList | [RFC5280] |
Note that these descriptions are not necessarily those used as labels for PEM formatted files defined in [RFC7468].
Console.WriteLine("Print type names of various ASN.1 data files..."); string fname, s; fname = "smallca.cer"; s = Asn1.Type(fname); Console.WriteLine("Asn1.Type('" + fname + "')=" + s); // Asn1.Type('smallca.cer')=X509 CERTIFICATE fname = "AlicePrivRSASign.p8e"; s = Asn1.Type(fname); Console.WriteLine("Asn1.Type('" + fname + "')=" + s); // Asn1.Type('AlicePrivRSASign.p8e')=PKCS8 ENCRYPTED PRIVATE KEY
VB6/C equivalent: ASN1_Type