In one of my previous posts, I described in detail for using X509 certificates with web services. Here are a couple more debugging tips that might also be helpful.
- RSA Key Length
One reason that the secure communication fails to establish is the mismatch in private/public key pairs. Ensuring the keys are of the same length should really be the first step before going much deeper into debugging.
- Proxy Server
You should be aware that if you are using a proxy server for your http traffic (you can check your browser settings to see if you are using a proxy server to connect to the network) and if you run into this exception
“The remote server returned an error: (502) Bad Gateway.”
Chances are that you are running through a proxy server and you should remove the proxy settings. And a simple fix would be to disable it (Internet Options -> Connections -> LAN Settings and uncheck Proxy Server). This will solve the problem.