msi将证书安装到currentuser

时间:2012-09-12 14:10:53

标签: c# certificate windows-installer

我有一个Visual Studio MSI安装程序,它应该将我的测试证书安装到当前用户,将我的测试CA安装到root,本地计算机。但对于当前用户,它不起作用。我没有收到任何错误,但它没有添加到其他证书中。 我的证书是嵌入式资源。

            using (Stream CertStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), @"Resources.client_certificate.cer"))
            {
                byte[] RawBytes = new byte[CertStream.Length];
                for (int Index = 0; Index < CertStream.Length; Index++)
                {
                    RawBytes[Index] = (byte)CertStream.ReadByte();
                }

                X509Certificate2 cert = new X509Certificate2(RawBytes);
                X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
                store.Open(OpenFlags.ReadWrite);
                store.Add(cert);
                store.Close();

我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

请注意,Microsoft已弃用该项目类型,并且不在VS2012中。此外,如果您转移到另一个工具(如WindowsInstaler XML),您将找到MSI扩展,无需编写自己的自定义操作即可使其更加轻松。如果您选择不转移到WiX,您可以在WiX中构建合并模块并将其合并到您的VDPROJ MSI中。

Certificate Element (Iis Extension)

Augmenting InstallShield using Windows Installer XML - Certificates

相关问题