Is it even possible? With bare http:
server := http.Server{
Addr: cfg.ListenHttps,
Handler: http.HandlerFunc(handler),
TLSConfig: tlsConf,
}
server.ListenAndServeTLS("", "")
@hryamzik Yes it is possible. You can find it here : https://golang.org/pkg/net/http/#Server.ListenAndServeTLS
Filenames containing a certificate and matching private key for the server must be provided if neither the Server's TLSConfig.Certificates nor TLSConfig.GetCertificate are populated
@aghasoroush I'm able to do this with net.http, the question is how to serve in the same way with gin?
Hi @hryamzik the example?
@thinkerou actually the question is how to run with multiple certificates, like here.
I'm looking to do the same thing. RunTLS uses http.ListenAndServeTLS which does not allow for the setting of TLSConfig.
https://github.com/gin-gonic/gin/blob/master/gin.go#L290
It would be nice if RunTLS used the Server.ListenAndServeTLS variant so that TLSConfig can be set.
https://golang.org/pkg/net/http/#Server.ListenAndServeTLS
Without this it's impossible to set ClientAuthType for TLS Client Authentication.
@hryamzik because ServeTLS only set one cert/key pair, it not support multiple certificates, see:
https://github.com/golang/go/blob/master/src/net/http/server.go#L2786
@thinkerou it's actually possible with net/http
I think you can do this code like in main function:
r := gin.Default()
server := http.Server{
Addr: addr,
Handler: r,
TLSConfig: tlsConfig,
}
err = server.ListenAndServeTLS("", "")
}
Can't check right now but if gin can be just set as a handler that should work, thanks!
Most helpful comment
I think you can do this code like in main function: