I'm new to ASP and I'm using csharp inside my html page. This is my code, clientcert is a base64 encoded cert. I can print that out on the screen fine. I can also print out a to the screen and know it's of type byte[]. However I get an error when I do the following.
<%@ Import Namespace="System" %> <%@ Import Namespace="System.Security.Cryptography.X509Certificates" %> <%@ Import Namespace="System.Text" %> <%@ Page Language="c#"%> <% string certPem = Request.Headers["ClientCert"]; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byte[] a = encoding.GetBytes(certPem); X509Certificate2 cer = new X509Certificate2(a); %> [CryptographicException: Cannot find the requested object. ] Exception Details: System.Security.Cryptography.CryptographicException: Cannot find the requested object. I'm wondering, why can I get a x509 object fine -- it works when doing new x509Certificate2(); with no arguments, but when passing it a byte array it just errors out.
1 Reset to default