2016-09-27 62 views
1

我已經上傳證書深入蔚藍新的門戶網站,而我沒有得到這些證書回到這裏是我的代碼天青不返回uploded證書

 var store = new X509Store(StoreName.My, StoreLocation.CurrentUser); 
     store.Open(OpenFlags.ReadOnly); 
     X509Certificate2Collection certificates = store.Certificates; 
     try 
     { 

     } 
     finally 
     { 
      store.Close(); 
     } 

     return certificates; 

這些證書,我總是得到

enter image description here

我還關注這篇文章https://azure.microsoft.com/en-us/blog/using-certificates-in-azure-websites-applications/

有人知道我爲什麼不是獲得所有證書以及爲什麼我獲得這些證書?請幫忙

+0

當你說沒有得到這些證書時,你的意思是在本地機器上運行代碼還是遠程調試託管應用程序? –

+0

我正在遠程調試應用程序。而不是將我剛剛收到的所有證書通過電子郵件發送出去並在本地環境中獲得安裝在我的計算機上的所有證書 –

+0

您是否在舊門戶的Settings-> Management Certificates部分添加了證書? –

回答

0

那麼,我使用這個功能,我已經找到了一個地方,工作正常。如果您已正確上傳所有證書,請嘗試運行這段代碼。我知道它看起來是一樣的,但你不能說真的。

private X509Certificate2 GetStoreCertificate(string thumbprint) 
    { 
     List<StoreLocation> locations = new List<StoreLocation> { StoreLocation.CurrentUser, StoreLocation.LocalMachine }; 

     foreach (var location in locations) 
     { 
      Console.WriteLine("location: " + location.ToString()); 
      X509Store store = new X509Store("My", location); 
      try 
      { 
       Console.WriteLine("Try, store.Open..."); 
       store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); 
       Console.WriteLine("store.Opened..." + store.Certificates.Count.ToString()); 

       foreach (X509Certificate2 cert in store.Certificates) 
       { 
        Console.WriteLine("X509Certificate2 Thumbprint : " + cert.Thumbprint); 
       } 

       foreach (X509Certificate cert in store.Certificates) 
       { 
        Console.WriteLine("X509Certificate Thumbprint : " + cert.Issuer); 
       } 

       X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false); 
       Console.WriteLine("Finding certificate.." + certificates.Count.ToString()); 
       if (certificates.Count == 1) 
       { 
        Console.WriteLine("Atleast one found!!!"); 
        return certificates[0]; 
       } 
      } 
      finally 
      { 
       store.Close(); 
      } 
     } 
     throw new ArgumentException(string.Format("A Certificate with Thumbprint '{0}' could not be located.", thumbprint)); 
    } 
+0

我有一個標準的1:小型訂閱?你有什麼計劃? –

+0

您的意思是應用程序服務計劃。是的,我有多個從基本到標準,我相信這並不重要,特別是如果你有一個標準的計劃 –

+0

我認爲你和我的代碼 –

1

代替geeting我剛收到這4個所有證書,並在當地enviorment我得到它們的所有證書在您的回覆幫助我的機器

上安裝從我的測試,the article我們在Azure web應用程序中使用證書。但是我們只能在下列條件下查詢證書:

1)證書已被上傳到Azure的Web應用程序
2)與它的價值Azure的門戶網站設置證書指紋

這是設置WEBSITE_LOAD_CERTIFICATES與您在本地計算機上的測試不同,因爲Azure Web應用程序在沙箱中運行。有關Azure Web應用沙箱的更多信息,請參閱this article

+0

是的!我已經做了你所提到的,我正在調試處於天藍色的託管應用程序 –