I have an application which runs certmgr.exe to install certificates at localMachine in root and personal folder. Following are the commands I am using
CertMgr.exe -add -all "secure\certs\cacert.crt" -s -r localMachine root
CertMgr.exe -add -all "secure\certs\server.p12" -s -r localMachine my
When I run these commands via command prompt to install these certificates respectively in windows7/8 platform, certificates get install and they work
But when I run the same command on windows 10 platform, certificates get installed in store but they don't work. Following error comes:
ERROR :-2506:Load device private key 'CN=ABB Authentication Server, OU=CSA, O=ABB' from windows store 'MY' failed ERROR :-2506:Cannot load private key/certificate pair from Windows store
Certificates are proper, I verified this by manually importing the certificates in mmc. When I imported manually, they started working. Clearly I could find that there is some problem with certmgr.exe or the access rights in windows 10 platform. I tried with different "certmgr.exe's" but could not solve the problem.
Ok,
Following code worked for me in .Net:
Dim store As New System.Security.Cryptography.X509Certificates.X509Store(X509Certificates.StoreName.Root, X509Certificates.StoreLocation.LocalMachine)
store.Open(X509Certificates.OpenFlags.ReadWrite)
Dim cert As New System.Security.Cryptography.X509Certificates.X509Certificate2("c:\cert.pfx", "password")
store.Add(cert)
store.Close()
尝试通过右键单击cmd app从system32文件夹中的“以管理员身份运行”选项从cmd运行CertMgr.exe。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.