Reputation: 219
I want to access the information (like issuer name, expiry date, etc) from .cer file .
I tried checking if the certificate is present in the store (it will not be present anyways since I didn't install the certificate)
X509Store store = new X509Store("test", StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindBySubjectName, certSearchString, false);
If it is not found, tried to read from the cer file following the below steps
X509Certificate2 cert = new X509Certificate2(byte value returned by the above step)
- In this step I'm getting an exception as follows:"System.Security.Cryptography.CryptographicException: Creating certificate object failed. The data passed in is either incorrect or is not supported by .NET Compact Framework. .NET Compact Framework does not support reading from pfx files."
Is there any way to install or access the information from cer file ?
It would be more useful if it could be done programmatically through invoking some exe or utility.
My aim is to validate all the web requests using the certificate. All that I have is only the cer file.
Is there any way to validate the web requests directly by using the cer file alone ?
Upvotes: 2
Views: 202
Reputation: 219
I have found the way to retrieve information from .cer file in Pocket PC device.
Firstly, Convert the cer file to DER encoded binary X.509 format (using computer) and then use it in the device.
Steps for conversion:
Copy the cer file (generated by the above process) to Pocket PC device and access the information programmatically as follows.
This solved my problem.
Upvotes: 1