Site in Azure Websites fails processing of X509Certificate2

前端 未结 6 1137
傲寒
傲寒 2020-12-13 18:09

I have site in Azure Websites (not Hosted Service) and I need processing .pfx certificates with private key there.

var x509Certificate2 = new X509Certificat         


        
6条回答
  •  抹茶落季
    2020-12-13 18:51

    I guess you found a workaround, but if others are struggling with this, I found the answer to this in another SO question:

    How can constructing an X509Certificate2 from a PKCS#12 byte array throw CryptographicException("The system cannot find the file specified.")?

    The magic is specifying the X509KeyStorageFlags storage flags. Example:

    var myCertificae = new X509Certificate2(
        certificateData,
        securePasswordString,
        X509KeyStorageFlags.MachineKeySet | 
        X509KeyStorageFlags.PersistKeySet | 
        X509KeyStorageFlags.Exportable);
    

提交回复
热议问题