X509Certificate Constructor Exception

后端 未结 9 1867
梦如初夏
梦如初夏 2020-11-27 15:38
//cert is an EF Entity and 
//    cert.CertificatePKCS12 is a byte[] with the certificate.

var certificate = new X509Certificate(cert.CertificatePKCS12, \"SomePassw         


        
9条回答
  •  盖世英雄少女心
    2020-11-27 16:16

    I had trouble on Windows 2012 Server R2 where my application could not load certificates for a PFX on disk. Things would work fine running my app as admin, and the exception said Access Denied so it had to be a permissions issue. I tried some of the above advice, but I still had the problem. I found that specifying the following flags as the third parameter of the cert constructor did the trick for me:

     X509KeyStorageFlags.UserKeySet | 
     X509KeyStorageFlags.PersistKeySet | 
     X509KeyStorageFlags.Exportable
    

提交回复
热议问题