2017-07-16 94 views

回答

4

根據您的描述,我認爲您可以按照以下步驟上傳您的PFX文件並從您的應用程序訪問它。

上傳PFX證書

登錄到portal.azure.com,選擇您的應用程序服務,然後單擊「設置> SSL證書」,然後單擊上傳證書添加您的PFX證書文件如下:

enter image description here

添加應用程序設置

點擊應用程序服務的「設置>應用程序設置」部分,如下添加一個名爲WEBSITE_LOAD_CERTIFICATES其值設置爲您上傳的PFX證書文件的指紋應用程序設置:

enter image description here

從應用程序訪問

你可以利用下面的代碼段用於檢索證書,如下所示:

X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); 
certStore.Open(OpenFlags.ReadOnly); 
X509Certificate2Collection certCollection = certStore.Certificates.Find(
         X509FindType.FindByThumbprint, 
         「{your-cert's-thumbprint}」, 
         false); 
// Get the first cert with the thumbprint 
if (certCollection.Count > 0) 
{ 
    X509Certificate2 cert = certCollection[0]; 
    // Use certificate 
    Console.WriteLine(cert.FriendlyName); 
} 
certStore.Close(); 

此外,這裏是以前的博客談論在Azure網站應用程序中使用證書,您可以參考here

相關問題