/** * Configure the pipeline for TLS NPN negotiation to HTTP/2. */ void ConfigureSsl(IChannel ch) { var tlsSettings = new ServerTlsSettings(this.tlsCertificate) { ApplicationProtocols = new List <SslApplicationProtocol>(new[] { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 }) }; tlsSettings.AllowAnyClientCertificate(); ch.Pipeline.AddLast(new TlsHandler(tlsSettings)); ch.Pipeline.AddLast(new Http2OrHttpHandler()); }
public Task <IChannel> StartAsync() { var bootstrap = new ServerBootstrap(); bootstrap.Group(_bossGroup, _workGroup); if (ServerSettings.UseLibuv) { bootstrap.Channel <TcpServerChannel>(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { bootstrap .Option(ChannelOption.SoReuseport, true) .ChildOption(ChannelOption.SoReuseaddr, true); } } else { bootstrap.Channel <TcpServerSocketChannel>(); } var tlsCertificate = new X509Certificate2(Path.Combine(ExampleHelper.ProcessDirectory, "dotnetty.com.pfx"), "password"); bootstrap .Option(ChannelOption.SoBacklog, 1024) //.Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default) .Handler(new LoggingHandler("LSTN")) .ChildHandler(new ActionChannelInitializer <IChannel>(ch => { var tlsSettings = new ServerTlsSettings(tlsCertificate) { ApplicationProtocols = new List <SslApplicationProtocol>(new[] { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 }) }; tlsSettings.AllowAnyClientCertificate(); ch.Pipeline.AddLast(new TlsHandler(tlsSettings)); ch.Pipeline.AddLast(new Http2OrHttpHandler()); })); return(bootstrap.BindAsync(IPAddress.Loopback, PORT)); }