0
我的目標是改變證書友好的名字,因爲我必須通過唯一的別名外部aplication ......我寫了這個:如何設置證書友好名稱
private void button1_Click(object sender, RoutedEventArgs e)
{
X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
X509Certificate2Collection fcollection = (X509Certificate2Collection)collection.Find(X509FindType.FindByTimeValid, DateTime.Now, false);
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Test Certificate Select", "Select a certificate from the following list to get information on that certificate", X509SelectionFlag.MultiSelection);
foreach (X509Certificate2 x509 in scollection)
{
try
{
String originName = friendlyNameOrigin(x509); //get orginal friendlyname
String nameNormalized = GetHashString(normalize(friendlyNameMy(x509))); //create 'uniqualy' name as md5 code
MessageBox.Show(x509.FriendlyName); //showed orginal name
x509.FriendlyName = nameNormalized;
MessageBox.Show(x509.FriendlyName); //showed new name
x509.Reset();
//next line - I started external aplication but it still see orginal name
//var processInfo = new ProcessStartInfo("java.exe", "-jar dist3/Signer.jar \"" + nameNormalized + "\" " + path);
//DO SOMETHING
//x509.FriendlyName = originName;
}
catch (CryptographicException)
{
MessageBox.Show("Information could not be written out for this certificate.");
}
}
store.Close();
}
此代碼更改友好名稱,但是Windows操作系統仍然看到舊名稱(當程序運行並在此之後)。這意味着設置友好名稱不會更改證書的友好名稱。
你能說我如何改變證書的友好名?
謝謝你的回答。