Cannot access cer text “App setting” in “Applicati

2019-09-15 22:53发布

问题:

I have a .cer file that I have converted into an "App settings" under "Application Settings" on Azure. I then add the setting key value pair in my app.config file with dummy info (and via "programmagic" is supposed to be updated when running on the Azure... The code works on my machine, but it is not getting pulled from my Azure "App settings" when I run it on Azure ... .

My "App Setting" in "Application Settings" on my MVC5 Web App:

Name: MyCER
Value: -----BEGIN CERTIFICATE----- goobledegookthatrunsfor1600charsOrSo -----END CERTIFICATE-----

My app.config reference:

<appSettings>
  <add key="CERFile" value="TEST"/>
</appSettings>

My code call (This works locally but not on Azure):

    Cert cert = new Cert();
    cert.LoadFromBase64(ConfigurationManager.AppSettings["CERFile"]);

Do I need to set permissions to allow this to work? I am also trying to do the same with my connection strings, and have not gotten that to work either.

回答1:

The correct way of using Certificates in Azure Webapps is https://azure.microsoft.com/en-us/blog/using-certificates-in-azure-websites-applications/

Any other way of constructing X509Certificate2 object will fail on Azure WebApps