6
我試圖在自定義操作中的本地計算機存儲中安裝證書。 將證書安裝,但是當我用它來查詢AWS,我得到這個錯誤:在.MSI中安裝證書自定義操作無法正常工作
Object contains only the public half of a key pair. A private key must also be provided.
安裝程序運行升高,目標是Windows Vista中。
如果我使用單獨的.exe來安裝完全相同的證書,使用完全相同的代碼,它的工作原理。 那麼,使用Windows安裝程序安裝證書時它有什麼不同?
代碼:
private void InstallCertificate(string certificatePath, string certificatePassword)
{
if (IsAdmin())
{
try
{
X509Certificate2 cert = new X509Certificate2(certificatePath, certificatePassword,
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);
store.Add(cert);
store.Close();
}
catch (Exception ex)
{
throw new DataException("Certificate appeared to load successfully but also seems to be null.", ex);
}
}
else
{
throw new Exception("Not enough priviliges to install certificate");
}
}