Steve
Steve

Reputation: 1082

Adding root certificate with CF 3.5

I have a problem with adding the my certificate file to the windows mobile x509 storage. I use the following test program:

byte[] certifictateData = FileToByteArray(appPath + "cert.cer");
X509Certificate certificate = new X509Certificate(certifictateData);

X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
int i = store.Certificates.Add(certificate);
store.Close();

On the device are 28 root certs installed. after adding my I receive 29 as value. but when I try to open store.Certificates[28] there is an OutOfRangeException Even after closing there is no entry in the certificate storage.

When I open the cert.cer file in the mobile browser it's added without any message.

What can I do?

Best regards

Upvotes: 2

Views: 846

Answers (2)

Steve
Steve

Reputation: 1082

This is what I also experienced with this namespace. Never the less you do a great job with the Small Device Framework.. this is my quick and cheaper solution ;)

ProcessStartInfo psi = new ProcessStartInfo(appPath + "cert.cer", "");
psi.UseShellExecute = true;
Process.Start(psi);

The only drawback is that a message pops up and shows the import result.

Upvotes: 1

ctacke
ctacke

Reputation: 67198

My experience is that the X509Store (really the entire namespace) in the Compact Framework is completely useless. I ended up implementing the entire set of APIs for importing both certificates and private keys. I put that work into the latest SDF, though IIRC someone found a bug in that code since, which I fixed internally, but I don't recall if that fix has propagated publicly.

Upvotes: 0

Related Questions