5

I'm having a Windows Store App (Metro App) which I want to connect a web service I built through HTTPS. And I am using a self-signed certificate for my web service. But when I tried to connect it from my App through System.Net.HttpClient.PostAsync I got an exception said

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

Inner exception said "The remote certificate is invalid according to the validation procedure."

I know this is because I'm using a self-signed certificate. I remembered in .NET I can use System.Net.ServicePointManager.ServerCertificateValidationCallback so that my application can pass the validation if the thumbprint is mine.

But I cannot find the relevant class/method in Windows Store runtime. How can I do that?

Shaun Xu
  • 4,476
  • 2
  • 27
  • 41
  • Duplicate of http://stackoverflow.com/questions/13119649/how-to-trust-a-self-signed-certificate-in-a-windows-store-app – ReinierDG Apr 08 '13 at 20:06

1 Answers1

0

First, you should ideally be using Windows.Web.HttpClient. On that API, you can use httpClient.HttpBaseProtocolFilter.IgnorableServerCertificateErrors to set the cert errors that you're willing to accept. You can choose to ignore the Untrusted error, for example, but you should then manually check the thumbprint before actually sending any data.

Mike Bishop
  • 134
  • 8
  • What if I am using [Microsoft.Net.Http](https://www.nuget.org/packages/Microsoft.Net.Http/) package? – TIKSN Mar 21 '15 at 10:35