Search code examples
c#x509certificate2

What file types does X509Certificate2 support?


I've got an admin page on my site were users can upload their public certificate to use for single sign-on (SAML2). I'm loading their certificate in to a X509Certificate2 object in order to display the common name, expiration date, etc. and I would like to be able to do some simple validation of the file before attempting to import it. In order to do that however I need to know what file types (ideally file extensions, but MIME type would suffice) are supported by the class. I've search around the MSDN/Google for a list and found nothing. Does anyone know?


Solution

  • As MSDN states https://msdn.microsoft.com/en-us/library/ms148413(v=vs.110).aspx

    The byte array can be binary (DER) encoded or Base64-encoded X.509 data. The byte array can also be a PKCS7 (Authenticode) signed file

    In this case only X509 certificates such as PFX/PKCS12.