Couldn’t establish trust relationship with web service over HTTPS

I'm running a web service on localhost for testing using HTTPS but my client app can't connect to the web service because of the following error:

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Here's my code for a user login:

private bool DoLogin(string EmailAddress, string Password) { try { WebClient client = new WebClient(); NameValueCollection credentials = new NameValueCollection { { "EmailAddress", EmailAddress }, { "Password", Password } }; client.QueryString = credentials; string result = client.DownloadString(new Uri("https://localhost/mywebservice/api/User/")); // check if a user record was returned by the service and create cookie etc... return true; } catch (Exception ex) { return false; } } 

I don't have any problem browsing to the web service though.

Also, I'm not even sure if I'm sending the credentials properly or what I need to do on the service to accept and use them…

by ortund via /r/csharp

Leave a Reply