[英]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.