Aishwaryameenakshi
Aishwaryameenakshi

Reputation: 219

How to install / access .cer file in Windows mobile 5.0 Pocket PC device?

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

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

Answers (1)

Aishwaryameenakshi
Aishwaryameenakshi

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:

  1. Open the .cer file in the computer
  2. Go to "Details" tab and click "Copy to File..." button
  3. Certificate Export Wizard appears in which click Next and choose "DER encoded binary X.509(.CER)"
  4. Click Next and specify the desired location and file name and click Finish
  5. This will generate a .cer file in the chosen location

Copy the cer file (generated by the above process) to Pocket PC device and access the information programmatically as follows.

  1. Read the contents of certificate file using BinaryReader which results in byte[] value
  2. X509Certificate2 cert = new X509Certificate2(byte value returned by the above step)
  3. Get the issuer name or any details required through built-in methods like cert.GetIssuerName();

This solved my problem.

Upvotes: 1

Related Questions