开发者

SSL Webservice Call Fails when called from within Windows Service

Have a webservice call from within a c# windows service. Service is behind an SSL cert. Certificate was registered into trusted root (password provided by provider).

Problem is that from the development machine verything works perfectly but once deployed onto production server, we keep on getting a 403 error.

Can browse to the service on the server, but get a cert popup?

No开发者_开发问答 proxy, firewall fine, direct connection out.

Any suggestions?


If you're getting a 403, that most likely means that the server is expecting some kind of credentials, and if you get a cert popup in your browser that most likely means that those credentials are a client certificate. (A 403 could also mean that the server doesn't like you for some other reason, like IP address, but given the circumstances this seems less likely.)

Assuming the service wants a client certificate, you would need to explicitly associate the client certificate with the call either through code or in your configuration file. (How you go about this would depend on whether you're using WCF or classic Web Reference web services.)

It sounds like the certificate you were given by the provider might be the client certificate the service is looking for. If so, it would need to go into the "My" store for LocalMachine rather than Trusted Roots (because a client certificate isn't going to be a root certificate), and you would need to configure your code to use it in the request.


You also need to add

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

if you get "cannot create trust relationship" crap message!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜