Hi, I’m trying to import a X509 certificate because I need to run a MQTT client over SSL. I’m using M2MQTT and works fine, but when I try to using it over SSL with X509 certificate I can`t find the way.
I tried to import the certificate with the Certificates application in Control Panel and then I run the example code below (C#) to test if I can get some certificate but the result in all stores is 0.
private static void DumpCertCounts()
{
var userStore = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
var deviceStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
Console.WriteLine(string.Format("Root: {0} {1}",userStore.Certificates.Count,deviceStore.Certificates.Count));
userStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
deviceStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
Console.WriteLine(string.Format("My: {0} {1}",userStore.Certificates.Count,deviceStore.Certificates.Count));
userStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.CurrentUser);
deviceStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.LocalMachine);
Console.WriteLine(string.Format("CA: {0} {1}",userStore.Certificates.Count,deviceStore.Certificates.Count));
}
Dou you have any example on how to do this? Or if there is a way of doing it in C I could pInvoke from C#.
Thanks in advanced.