return ssl alert unrecognized_name when https domain not registered (#3620)

This commit is contained in:
Zeyu Dong
2023-09-18 02:28:05 -04:00
committed by GitHub
parent bae0b4d7c0
commit 5c8ea51eb5
5 changed files with 28 additions and 9 deletions

View File

@@ -29,6 +29,7 @@ type HTTPSMuxer struct {
func NewHTTPSMuxer(listener net.Listener, timeout time.Duration) (*HTTPSMuxer, error) {
mux, err := NewMuxer(listener, GetHTTPSHostname, timeout)
mux.SetFailHookFunc(vhostFailed)
if err != nil {
return nil, err
}
@@ -69,6 +70,12 @@ func readClientHello(reader io.Reader) (*tls.ClientHelloInfo, error) {
return hello, nil
}
func vhostFailed(c net.Conn) {
// Alert with alertUnrecognizedName
_ = tls.Server(c, &tls.Config{}).Handshake()
c.Close()
}
type readOnlyConn struct {
reader io.Reader
}