Windows Store apps: hostname in certificate is invalid or does not match

in my Windows 8.1 application, when I call the web service, I get the following exception:

The host name in the certificate is invalid or does not match

The code I'm using is:

HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter(); filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted); HttpClient client = new HttpClient(filter); HttpResponseMessage msg = await client.GetAsync(new Uri("[Service_URL]",UriKind.Absolute)); IRandomAccessStream randomAccessStream=(IRandomAccessStream)await msg.Content.ReadAsInputStreamAsync(); 

I use HttpBaseProtocolFilter to bypass errors that may be with the server certificate, but it seems that it did not overcome the above exception.

Is there a workaround for this?

+3
source share
1 answer

Try:

 filter.IgnorableServerCertificateErrors.Add( ChainValidationResult.Untrusted | ChainValidationResult.InvalidName); 

For more viewing information, see the ChainValitadionResult enumeration.

+7
source

All Articles