简体   繁体   English

c#调用Web服务错误:“未提供客户端证书。 在客户端凭据中指定客户端证书”

[英]c# calling web service error: “The client certificate is Not provided. Specify a client certificate in client credentials”

I am trying to call a web service on my server over https from my mvc3 app. 我试图通过我的mvc3应用通过https调用服务器上的Web服务。 I have web services located at this address: 我的Web服务位于此地址:

https:localhost/web_services/web_services.asmx

And in my code i try to connect like this: 在我的代码中,我尝试这样连接:

 var binding = new BasicHttpsBinding();
 binding.maxbuffersize = 10000;
 binding.maxbufferPoolsize = 10000; 
 binding.maxreceivedmessageSize= 10000;
 binding.Security.Mode = System.ServiceModel.BasicHttpsSecurityMode.Transport;
 binding.Security.Transport.ClientCredentialsType = HttpClientCredentialType.Certificate


 var endpointAddress = new EndpointAddress("https:/localhost/web_services/web_services.asmx");
 new ChannelFactory<ws_name_webreqSoap>(basicHttpsBinding, endpointAddress).CreateChannel();
 var webServices = new ws_name_webreqSoapClient(basicHttpsBinding, endpointAddress);

However, when this runs on the server, i get the following message: 但是,当它在服务器上运行时,我收到以下消息:

"The client certificate is Not provided. Specify a client certificate in client credentials" “未提供客户端证书。在客户端凭据中指定客户端证书”

My knowledge of HTTPS and certificates is limited. 我对HTTPS和证书的了解有限。 Does anyone know a solution to this? 有人知道解决方案吗?

Thanks, 谢谢,

You can specify the client certificate on the ChannelFactory: 您可以在ChannelFactory上指定客户端证书:

var channelFactory = new ChannelFactory<ws_name_webreqSoap>(basicHttpsBinding, endpointAddress);
channelFactory.Credentials.ClientCertificate.SetCertificate("CN=client.com", StoreLocation.CurrentUser, StoreName.My);
var channel = channelFactory.CreateChannel();
// ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TLS 1.2错误-未提供客户端证书。 在ClientCredentials中指定客户端证书 - TLS 1.2 Error - The client certificate is not provided. Specify a client certificate in ClientCredentials 如何使用C#的客户端证书调用Web服务? - How to call web service with client certificate from C#? C# 连接到 Ravendb 一直失败并出现错误:此服务器需要客户端证书进行身份验证,但客户端未提供任何证书 - C# Connect to Ravendb keeps failing with error: This server requires client certificate for authentication, but none was provided by the client WCF:未提供服务证书。 在ServiceCredentials中指定服务证书 - WCF: The service certificate is not provided. Specify a service certificate in ServiceCredentials WCF-调用WCF服务的WCF客户端出现“未为目标提供服务证书”错误 - WCF - 'The service certificate is not provided for target' error for WCF client calling a WCF service c#没有客户端证书的TLS客户端 - c# TLS client without client certificate 调用Web服务时在客户端找不到证书 - Cannot find certificate in client side while calling web service 在C#客户端中调用SOAP Web服务 - Calling a SOAP web service in a C# client 使用基本身份验证和客户端证书调用WCF服务 - Calling WCF Service with basic auth and client certificate 使用客户端证书身份验证连接到Web服务 - Connecting to a Web Service using Client Certificate authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM