Embedio: Does embedio lib support https?

Created on 7 Apr 2017  Â·  18Comments  Â·  Source: unosquare/embedio

We have been using this lib as a test web server before we push content to Akamai. It has been serving us well. It is simple to use and rock solid.

We have clients that need to access content over https. Does this lib support creating a https server with a self signed cert?
If not, do you have any pointers to get there?

Thanks

Most helpful comment

   private static WebServer CreateWebServer(string url,int port)
        {
            // Ssl Support :
            var ca1 = new X509Certificate2Builder { SubjectName = "CN=SomeCA" }.Build();
            var cert1 = new X509Certificate2Builder { SubjectName = "CN=SelfSignedCert", Issuer = ca1, Intermediate = false }.Build();
            var server = new WebServer(o => o
                    .WithMode(HttpListenerMode.EmbedIO)
                    .WithCertificate(cert1)
                    .WithUrlPrefix("https://*:" + port))

                // First, we will configure our web server by adding Modules.
                .WithStaticFolder("/", SimpleLogManager.CurrentDirectory, true,m =>
                {
                    m.WithDirectoryLister(DirectoryLister.Html).WithoutDefaultDocument().WithContentCaching(false);
                })
                .WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" }))); ;

            return server;
        }

All 18 comments

Hi, we have a closed issue related #26

Right now, we don't have plans to support HTTPS.

That link seem to be about wss which probably based on https. My request is for https only. Looking at all the links referenced in the other issue, https support seem to be built in HttpListener of .Net assuming user configured things right using netsh.

Am I on the right path if I were to do the same?

Yes, if you are using the .NET HttpListener you can use HTTPS with a manual binding. But you can't run EmbedIO with Net Standard or Mono. The HttpListener implementation that we maintain doesn't support HTTPS.

I am using older version of your lib. I believe I used version that was latest around an year back. I am using it from a .Net 4.5 winforms application.
Did this version has same limitation as above?

Yes, to use the net framework httplistener you need to upgrade to 4.6

On Apr 8, 2017 8:44 AM, "videoguy" notifications@github.com wrote:

I am using older version of your lib. I believe I used version that was
latest around an year back. I am using it from a .Net 4.5 winforms
application.
Did this version has same limitation as above?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/unosquare/embedio/issues/72#issuecomment-292719048,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABsYsOBnAsHXpJJPmNGv_g7Z0B9ZkmQ2ks5rt49WgaJpZM4M2aQD
.

I am confused. From what I understand, embedio implementation of web server doesn't use .Net builtin HttpListener (and http.sys). Instead it implements web server on top of tcp sockets. And it doesn't support https.

What I am confused about is how embedio will help even if I move to .Net 4.6. You are not using the builtin HttpListener. Does it matter what .Net framework I use?

Thanks

Yes, only target NET46 is using the builtin HttpListener.

If I understand this correctly, all I have to do is change my winforms project settings to use .Net 4.6 and rebuild the app. Then embedio uses builtin httplistener for all the http traffic.

Yes. It's right.

On Tue, Apr 11, 2017 at 3:21 PM, videoguy notifications@github.com wrote:

If I understand this correctly, all I have to do is change my winforms
project settings to use .Net 4.6 and rebuild the app. Then embedio uses
builtin httplistener for all the http traffic.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/unosquare/embedio/issues/72#issuecomment-293388619,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABsYsPEr7q7Z88q-QucIc-mJEk0j-95bks5ru-DDgaJpZM4M2aQD
.

--
Geo Pérez

Thats great! In this case, can my app listen and accept https connections and serve static files?
I am assuming yes as the https is builtin the kernel driver (http.sys).
I understand I have to go do all the netsh configuration stuff to get it working.

You are right. You application can use the builtin httplistener and you need to setup the netsh to handle SSL.

It worked. I am able to use embedio with .Net 4.6.1 serve https content on localhost.

I looked at other options for https. I always come back to embedio as it has been serving us well and is a rock solid web server for our use case.

Thanks a lot for your help!

Cool. Closing ticket.

@geoperez please did you do any investigation of other solutions like websocket-sharp for that? SSL for both HTTP and WebSocket is critical for our new project (will be .NETStandard based, .NET 4.6 is not enough for us). I don't know if there are any issuses with classes like SslStream or X509Certificate with .NETStandard? If you don't know about any and the decision not to support SSL is only about the time/timeplan, I could invest some time to implement it...

Hi @buvar, the reason we are not supporting SSL is because time, but if you provide a solution it's welcome

@videoguy can you post a code snippet how you used EmbedIO with SSL?

   private static WebServer CreateWebServer(string url,int port)
        {
            // Ssl Support :
            var ca1 = new X509Certificate2Builder { SubjectName = "CN=SomeCA" }.Build();
            var cert1 = new X509Certificate2Builder { SubjectName = "CN=SelfSignedCert", Issuer = ca1, Intermediate = false }.Build();
            var server = new WebServer(o => o
                    .WithMode(HttpListenerMode.EmbedIO)
                    .WithCertificate(cert1)
                    .WithUrlPrefix("https://*:" + port))

                // First, we will configure our web server by adding Modules.
                .WithStaticFolder("/", SimpleLogManager.CurrentDirectory, true,m =>
                {
                    m.WithDirectoryLister(DirectoryLister.Html).WithoutDefaultDocument().WithContentCaching(false);
                })
                .WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" }))); ;

            return server;
        }

@OneB1t I know this is an old closed thread but .... Is the X509CertificateBuilder class in your example from the Mono.Security Library ?

Was this page helpful?
0 / 5 - 0 ratings