From 4f75fe12cd648160d7d3b12b276134ff1a199eaa Mon Sep 17 00:00:00 2001 From: Romain Beuque <556072+rbeuque74@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:30:38 +0100 Subject: [PATCH] feat(tonic/listen): handle TLSConfig with custom GetCertificate or GetConfigForClient function Signed-off-by: Romain Beuque <556072+rbeuque74@users.noreply.github.com> --- tonic/listen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tonic/listen.go b/tonic/listen.go index 7af42d6..218a675 100644 --- a/tonic/listen.go +++ b/tonic/listen.go @@ -59,7 +59,7 @@ func ListenAndServe(handler http.Handler, errorHandler func(error), opt ...Liste // delayed listen, store it in the original listener object so any wrapping listener from listenOpt // will have a correct reference listener.Listener = ln - if srv.TLSConfig != nil && len(srv.TLSConfig.Certificates) > 0 { + if srv.TLSConfig != nil && (len(srv.TLSConfig.Certificates) > 0 || srv.TLSConfig.GetCertificate != nil || srv.TLSConfig.GetConfigForClient != nil) { // ServeTLS without cert files lets listenOpts set srv.TLSConfig.Certificates err = listenOpt.Server.ServeTLS(listenOpt.Listener, "", "") } else {