C#/UWP : How to manage certificate errors with HttpClient?

0

I've developed an UWP app for a client, which uses WebServices that are hosted in its domain.

  • Until now, the URL WebServices were related to a test server that don't use SSL

  • But now, the WebServices URL are related to the prod server that use SSL

As I'm a subcontractor, I don't have an AD account, and I need to use the VPN to access to the client's WebServices.

I didn't get any problem to access to the test server, but it's no longer the case with the prod server.

When I try to access to access to the URL through a navigator, I get a security warning message (DLG_FLAGS_INVALID_CA), but I can "force" the navigation to the URL.

But when I call the WebService from the app with HttpCLient, I also get an error (HttpRequestException) and I don't see how I could fix it.

Here are the details of the exception:

HResult = -2147012851

InnerException = {System.Runtime.InteropServices.COMException (0x80072F0D): Can't find text related to the error code. The certificate authority is invalid or is incorrect at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) ...

Message = "An error occurred while sending the request."

Source = "System.Net.Http"

I've already tried to install handly the certificates on my computer, but this doesn't fix the issue...

Is there another approach?

Edit: add "user" certificate

The client sent me the "user" certificate and I installed it on my computer in "User\Trusted Root Certification Authorities Certificate Store": there is no longer problem from the navigator. However, in the app, the problem is still present.

Is it normal? Do I need to "attach" the certificate to the app? This is not really usefull, as the client's users don't need this problem: it's only me as I'm a subcontractor using the VPN...

Edit: add "computer" certificate

Finally the client sent me the "computer" certificate and I installed it on my computer in "Computer\Trusted Root Certification Authorities Certificate Store": this time I could use the app without problem.

It's good to know that the UWP app and the navigators don't use the same certificate.

c#
ssl
uwp
certificate
httpclient
asked on Stack Overflow Apr 17, 2018 by Gold.strike • edited Apr 18, 2018 by Gold.strike

1 Answer

0

The problem has been fixed by installing the "user" and "computer" certificates that has been sent by the client.

answered on Stack Overflow Apr 18, 2018 by Gold.strike

User contributions licensed under CC BY-SA 3.0