From 939c0605137b4dd7033e1c669d161324b210b2af Mon Sep 17 00:00:00 2001 From: Adphi Date: Sat, 21 Dec 2024 14:44:56 +0100 Subject: [PATCH] service: fix alpn certificate usage Signed-off-by: Adphi --- service/options.go | 3 +++ service/service.go | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/service/options.go b/service/options.go index cde8460..5f600ac 100644 --- a/service/options.go +++ b/service/options.go @@ -566,6 +566,7 @@ func (o *options) parseTLSConfig() error { if o.tlsConfig != nil { return nil } + nextProtos := []string{"h2", "h2c", "http/1.1", "acme-tls/1"} if !o.hasTLSConfig() { if !o.secure { return nil @@ -593,6 +594,7 @@ func (o *options) parseTLSConfig() error { o.tlsConfig = &tls.Config{ Certificates: []tls.Certificate{cert}, ClientAuth: tls.NoClientCert, + NextProtos: nextProtos, } return nil } @@ -612,6 +614,7 @@ func (o *options) parseTLSConfig() error { o.tlsConfig = &tls.Config{ Certificates: []tls.Certificate{cert}, RootCAs: caCertPool, + NextProtos: nextProtos, } if !o.hasClientTLSConfig() { return nil diff --git a/service/service.go b/service/service.go index 31ed7db..af6c2f9 100644 --- a/service/service.go +++ b/service/service.go @@ -310,7 +310,6 @@ func (s *service) runWithoutCmux(ctx context.Context, g *errgroup.Group) error { handler.ServeHTTP(w, r) } }), &http2.Server{}), - TLSConfig: s.opts.tlsConfig, } if err := http2.ConfigureServer(hServer, &http2.Server{}); err != nil { return err @@ -336,8 +335,7 @@ func (s *service) runWithCmux(ctx context.Context, g *errgroup.Group) error { if s.opts.mux != nil { hServer := &http.Server{ - Handler: alice.New(s.opts.middlewares...).Then(cors.New(s.opts.cors).Handler(s.opts.mux)), - TLSConfig: s.opts.tlsConfig, + Handler: alice.New(s.opts.middlewares...).Then(cors.New(s.opts.cors).Handler(s.opts.mux)), } g.Go(func() error { defer hServer.Shutdown(ctx)