我有一个 Visual Studio MSI 安装程序,它应该将我的测试证书安装到当前用户,并将我的测试 CA 安装到根本地计算机。但对于当前用户,它不起作用。我没有收到错误,但它没有添加到其他证书中。我的证书是嵌入式资源。
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();
我错过了什么吗?