Share via

HTTPListener to implement HTTPS server

S Abijith 496 Reputation points
2021-01-13T09:39:47.503+00:00

Hi All,
We are trying to upload a configuration file to a device using the HTTPS protocol using a WPF C# application built on .Net 4.5 Framework. Below are the steps that take place during the communication:
Initially, the WPF application sends an SNMP request to the device for uploading the configuration file. The request contains the URL and a file download trigger.
The URL contains the path/location on the HTTPS server where the configuration file is present including the file name. The trigger is to initiate the file download to the device.
Once the device receives the URL and the trigger, it tries to perform a TLS handshake, certificate verification, and exchange of private keys.
Once the TLS handshake, certificate verification, and the exchange of keys are successful, the file will be uploaded to the device.

For this purpose, we are trying to set up an HTTPS server. We are trying to implement an HTTPS server by creating a console application using HTTPListener class using .Net 4.5 Framework. I have attached the code for the same in the question.

We have a couple of questions regarding this:
When we try to initiate a trigger an HTTPS request to the HTTPListener application from the browser, we get a not trusted page. Once we click on the proceed to page, the configuration file will be loaded on the browser. Is this an expected behavior? If yes, how do we get rid of this behavior?
Is the code attached in the question enough to complete the TLS handshake and exchange the certificate key too, or does it need any additional code?
Does the certificate have to be in the trusted store in order for the exchange to take place, or can it be present in any random location on the HTTPS server?

Please let us know about this. Any help would be appreciated. Thank you!!

Developer technologies | Windows Presentation Foundation
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.