将.pfx证书附加到exe文件 [英] Attach .pfx certificate to exe file
问题描述
我必须将软件部署到n个客户端,这些客户端将安装证书并使用它。我不想部署两个文件(.pfx和exe)只有一个(.exe将包含.pfx)。
我现在做的是
X509Certificate2 ^ x509 = gcnew X509Certificate2;
x509->导入(C:
有可能吗?
您可以随时将证书数据嵌入为资源。
您是否能够安全地分发可执行文件?
以下是一些粗略的步骤,摘自: http:// www。 spikezilla-software.com/blog/?p=24
- 将PFX添加到项目中。然后单击该文件,并在属性窗口中将构建操作设置为嵌入资源
- 读取嵌入的PFX文件并导入证书
这是C#,但你应该能够很容易地翻译成C ++ / CLI:
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);
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
- Add the PFX to your project. Then click once on the file, and in the Properties window, set the Build Action to Embedded Resource
- Read the embedded PFX file and import the certificate
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");
这篇关于将.pfx证书附加到exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!