[英]Why I can't find the certificate in a WCF Service?
我正在嘗試使用WCF開發服務,但是找不到我創建的證書,該證書位於TrustedPeple文件夾下。 到目前為止,這是我編寫的代碼塊:
client.ClientCredentials.ServiceCertificate.SetDefaultCertificate(
StoreLocation.CurrentUser,
StoreName.My,
X509FindType.FindBySubjectName,
"WCfClient");
從上面的代碼中可以看到,我還嘗試了手動設置證書特征,但仍然找不到。
另外,我還將發布conif xml文件的一部分,以更好地理解:
<services>
<service
name="XMLServices.CriDecServices.CriDecService"
behaviorConfiguration="wsHttpCertificateBehavior">
<endpoint name="CriDecPoint"
address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttpEndpointBinding"
contract="XMLContracts.ServiceContracts.ICriDecService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/XMLServices/CriDecServices/CriDecService" />
</baseAddresses>
</host>
</service>
<service
name="XMLServices.UtenteServices.UtenteService"
behaviorConfiguration="wsHttpCertificateBehavior">
<endpoint
name="UserPoint"
address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttpEndpointBinding"
contract="XMLContracts.ServiceContracts.IUtenteService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8766/XMLServices/UtenteServices/UtenteService" />
</baseAddresses>
</host>
</service>
</services>
這是我得到的例外:
“未提供客戶端證書。在ClientCredentials中指定客戶端證書。”
誰能幫我了解為什么我似乎找不到證書? 謝謝
如果您在此處查看,您會發現您嘗試使用的商店不是Trusted People文件夾中的商店,而是個人文件夾中的商店
你應該使用
StoreName.TrustedPeople
您也很可能需要StoreLocation.LocalMachine。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.