jgauffin / Griffin.WebServer

A web server built on top of Griffin.Framework
107 stars 42 forks source link

HTTPS support. #13

Closed PhonicUK closed 9 years ago

PhonicUK commented 10 years ago

It'd be very nice to see HTTPS support like the old standalone webserver component had. Especially if it can be implemented using TLS. I'd be quite happy to throw some money at whoever can make this happen.

cocowalla commented 10 years ago

+1

jgauffin commented 9 years ago

Here is how you do it in the Griffin.Framework branch:

 var listener = new HttpListener();
            listener.ChannelFactory = new SecureTcpChannelFactory(new ServerSideSslStreamBuilder(certificate));
            listener.ClientConnected += OnConnect;
            listener.MessageReceived = OnMessage;
            listener.BodyDecoder = new CompositeIMessageSerializer();
            listener.Start(IPAddress.Any, 8083);
cocowalla commented 9 years ago

Does this support client certificates too?

jgauffin commented 9 years ago

Yes, use the ClientSideSslStreamBuilder instead.

jgauffin commented 9 years ago

Sorry, wrong of me. Just set the UseClientCertificate to true in the ServerSideSslStreamBuilder

cocowalla commented 9 years ago

Great :)

What about performing authentication of the certificates provided by clients, is there an event handler to hook into? Or better yet, is there a sample that includes the use of client certificates?

jgauffin commented 9 years ago

Create MyServerSideSslStreamBuilder and override OnRemoteCertifiateValidation

jgauffin commented 9 years ago

It works like described at MSDN: http://msdn.microsoft.com/en-us/library/system.net.security.remotecertificatevalidationcallback(v=vs.110).aspx

PhonicUK commented 9 years ago

Is the Griffin.Framework branch the same Griffin.Framework I can now see on NuGet?

jgauffin commented 9 years ago

yes

jgauffin commented 9 years ago

It's the official branch now