Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/tls: oversized record received with length 20037 #19493

Closed
huzeyfecoskun opened this issue Mar 10, 2017 · 7 comments
Closed

crypto/tls: oversized record received with length 20037 #19493

huzeyfecoskun opened this issue Mar 10, 2017 · 7 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@huzeyfecoskun
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go 1.8

What operating system and processor architecture are you using (go env)?

windows

What did you do?

Tls listener is not working as expected.

error
tls: oversized record received with length 20037

What did you expect to see?

i try to read tls connection

What did you see instead?

tls: oversized record received with length 20037

@mvdan
Copy link
Member

mvdan commented Mar 10, 2017

This isn't enough information. Can you share a piece of code to reproduce the issue? If not, could you describe what the code was doing when this happened?

@mvdan mvdan changed the title tls: oversized record received with length 20037 crypto/tls: oversized record received with length 20037 Mar 10, 2017
@mvdan mvdan added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 10, 2017
@bradfitz bradfitz added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 21, 2017
@bradfitz bradfitz added this to the Go1.9Maybe milestone Mar 21, 2017
@FiloSottile
Copy link
Contributor

That looks a lot like trying to connect to a TLS listener with another protocol, for example plain HTTP. If that's not it, we will probably need to see the client or a pcap to debug this.

@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@henvic
Copy link
Contributor

henvic commented May 10, 2017

I just had a similar error... and found the following behavior weird...

Is it expected Go spitting out errors like this?

package main

import (
	"fmt"
	"net/http"
	"net/http/httptest"
	"net/url"
	"os"
)

func main() {
	var Mux = http.NewServeMux()
	var server = httptest.NewTLSServer(Mux)

	transport := &http.Transport{
		Proxy: func(req *http.Request) (*url.URL, error) {
			return url.Parse(server.URL)
		},
	}

	var r, err = http.NewRequest("GET", "https://example.com/", nil)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Unexpected error: %v\n", err)
	}

	_, err = (&http.Client{Transport: transport}).Do(r)

	if err != nil {
		fmt.Fprintf(os.Stderr, "\n\n\nUnexpected request error: %v\n", err)
	}
}

When running:

$ go run foo.go
2017/05/10 10:03:18 http: TLS handshake error from 127.0.0.1:55829: tls: oversized record received with length 20037



Unexpected request error: Get https://example.com/: malformed HTTP response "\x15\x03\x01\x00\x02\x02\x16"

Notice I never printed the "TLS handshake error" error. Go just printed it to stderr. I found it really weird comparing how Go handles errors elsewhere.

Update: Actually I see it is working as intended given that http.ErrorLog is nil (

go/src/net/http/server.go

Lines 2374 to 2378 in 48def43

// ErrorLog specifies an optional logger for errors accepting
// connections and unexpected behavior from handlers.
// If nil, logging goes to os.Stderr via the log package's
// standard logger.
ErrorLog *log.Logger
), however the returned error value could be better, couldn't it?

@mvdan
Copy link
Member

mvdan commented Sep 25, 2017

Funnily enough, I hit this myself today trying to write a test.

@henvic your example is similar to what I was writing, and both are wrong:

    // Proxy specifies a function to return a proxy for a given
    // Request. If the function returns a non-nil error, the
    // request is aborted with the provided error.
    //
    // The proxy type is determined by the URL scheme. "http"
    // and "socks5" are supported. If the scheme is empty,
    // "http" is assumed.
    //
    // If Proxy is nil or returns a nil *URL, no proxy is used.

Note that the "https" scheme isn't supported. I wonder if a better error should be given, as I was stuck on this for a good 20 minutes.

@mvdan
Copy link
Member

mvdan commented Sep 25, 2017

Sending a CL with a better error.

@gopherbot
Copy link

Change https://golang.org/cl/66010 mentions this issue: net/http: error if Transport.Proxy returns https

gopherbot pushed a commit that referenced this issue Sep 26, 2017
Transport.Proxy is documented as only supporting the http and socks5
schemes. If one tries to use it for https URLs, they end up with a
cryptic error like:

	http: TLS handshake error from [...]: tls: oversized record received with length 20037

This is because Transport simply skips TLS if Proxy is non-nil, since it
knows it doesn't support Proxy with https.

However, that error is very confusing and it can take a while to figure
out what's going on. Instead, error if Proxy is used and it returns an
unsupported scheme.

Updates #19493.

Change-Id: Ia036357011752f45bb9b8282a4ab5e31bc8d1a69
Reviewed-on: https://go-review.googlesource.com/66010
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
@golang golang locked and limited conversation to collaborators Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants