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
- Read the contents of certificate file using BinaryReader which results in byte[] value
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 ?