2017-04-10 116 views
0

我創建的驗證方法簡單的WCF項目,這個配置你可以看到:找不到X.509證書:STORENAME「我」,StoreLocation「LOCALMACHINE」

 <serviceCertificate findValue="STSTestCert" 
          storeLocation="LocalMachine" 
          x509FindType="FindBySubjectName" 
          storeName="My"/> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<protocolMapping> 
    <add binding="basicHttpsBinding" scheme="https"/> 
</protocolMapping>  
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/> 

但是當我運行該項目,我得到這個錯誤:

不能使用下面的搜索找到的X.509證書CRI teria:StoreName'我',StoreLocation'LocalMachine',FindType'FindBySubjectName',FindValue'STSTestCert'。 描述:執行當前Web請求期間發生未處理的異常。請查看堆棧跟蹤以獲取有關該錯誤的更多信息以及源代碼的位置。

異常詳細信息:System.InvalidOperationException:使用以下搜索條件找不到X.509證書:StoreName'My',StoreLocation'LocalMachine',FindType'FindBySubjectName',FindValue'STSTestCert'。

回答

0

您確定證書已安裝嗎?例如,如果您嘗試使用PowerShell dir cert:\LocalMachine\My,那麼您是否在那裏找到證書STSTestCert?如果沒有,那麼你可能安裝在別的地方。也許當你安裝它時,你沒有明確指定Personal文件夾(因爲這是My這裏的意思)