Skip to content

ListenAndServeTLS becomes unresponsive when accessing with wrong protocol #2253

Description

@gopherbot

by branimirkaradzic:

What steps will reproduce the problem?

To reproduce the bug, you have to run TLS server and then open two browser windows and
point one to:

http://localhost:443/

And other to:

https://localhost/


What is the expected output?

I expect that connection on the first one gets rejected and closed as
soon as server figures out that protocol is not HTTPS, and that other
one just works.


What do you see instead?

Server becomes unresponsive.


Which compiler are you using (5g, 6g, 8g, gccgo)?

6g


Which operating system are you using?

Linux


Which revision are you using?  (hg identify)

version: release.r60 9481
b0819469a6df (release-branch.r60) release/release.r60


Please provide any additional information below.

Here is simple code to reproduce the bug:

package main

import (
        "http"
)

func index(w http.ResponseWriter, req *http.Request) {

        w.Write([]byte("Hello!"))

}

func main() {

        http.HandleFunc("/", index)
        server := &http.Server{Addr: ":443", Handler: nil, ReadTimeout: 10 *
1e9, WriteTimeout: 10 * 1e9}
        server.ListenAndServeTLS("cert.pem", "key.pem")

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions