I have to deploy a software to n clients that will install a certificate and use it. I don't want to deploy two files (.pfx and exe) just one (.exe that will contain the .pfx).
What i'm doing now is import the certificate from a location.
X509Certificate2^ x509 = gcnew X509Certificate2;
x509->Import( "C:\\Tmp\\certficate.pfx" );
Is it possible ?
You could always embed the certificate data as a resource.
One warning though: if someone gets the executable, they can pull out the PFX file pretty easily.
Are you able to securely distribute the executable?
Here are some rough steps, distilled from: http://www.spikezilla-software.com/blog/?p=24
This is C# but you should be able to translate to C++/CLI pretty easily:
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MyFile.pfx");
var bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
var cert = new X509Certificate2(bytes, "certPassword");