Search code examples
c#.net-2.0smart-device

Making a HTTPS request using C# Smart Device Project .net 2.0


I am working on a Windows Smart Device project. I want to send a HTTPS request to a API host to retrieve information.

The current code noted in the link below works perfectly on my trial on a Windows Form application:

How do I use WebRequest to access an SSL encrypted site using https?

However, this does not work in a Smart Device application as I do not have access to System.Net.Security on the Smart Device project (In fact there is only System.Net.Sockets under System.Net, rendering me unable to use the same method for queries outside of non-SSL sites.

Is there a workaround for the same solution to be able to make HTTPS requests?

EDIT: I know that Google Maps is a bad example, especially when their API keys are insecurely sent over the HTTPS GET method usually and it is better to use a server to secure the requests.


Solution

  • Got the answer to my own problem.

    I could create a C++ module to handle the HTTPS requests instead, and using C#'s pinvoke method to call the C++ module and returning the results.

    Alternatively I could use make a server that handles HTTP requests like a middleman, similar to the C++ module. This server makes the HTTPS requests on behalf of the Smart Device Application to return the results.

    TL;DR it is nothing much but just using the middleman approach to solve the problem since there is no function in the Smart Device Application template that could handle HTTPS requests.