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

net::ERR_CONNECTION_CLOSED net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH #580

Closed
breezemight opened this issue Apr 14, 2022 · 9 comments
Closed
Labels
question Questions related to rod

Comments

@breezemight
Copy link

breezemight commented Apr 14, 2022

Rod Version: v0.105.1

Screenshotting urls with bad ssl certificate fails and raises error.

The code I wrote :

func main() {
        path := "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
        u := launcher.New().Bin(path).MustLaunch()

        screenshot("https://urlwithbadssl.com", u)
}

func screenshot(uri, u string) {

	buf, err := rod.New().ControlURL(u).MustConnect().MustPage(uri).
		MustWaitLoad().Screenshot(true, &proto.PageCaptureScreenshot{
		Format:  proto.PageCaptureScreenshotFormatJpeg,
		Quality: gson.Int(90),
	})

	if err != nil {
		log.Fatal(uri, ":", err)
	}

	err = ioutil.WriteFile(<path code here>, buf, 0644)
	if err != nil {
		log.Fatal(err)
	}
}

Error raised by it :

panic: navigation failed: net::ERR_CONNECTION_CLOSED

goroutine 160 [running]:
github.com/go-rod/rod/lib/utils.glob..func2({0x6558a0?, 0xc00038ce50?})
	C:/Users/User/go/pkg/mod/github.com/go-rod/rod@v0.105.1/lib/utils/utils.go:57 +0x25
github.com/go-rod/rod.genE.func1({0xc00040d250?, 0x17?, 0x0?})
	C:/Users/User/go/pkg/mod/github.com/go-rod/rod@v0.105.1/must.go:35 +0x5a
github.com/go-rod/rod.(*Browser).MustPage(0xc00029a700, {0xc0005edef8?, 0x0?, 0x0?})
	C:/Users/User/go/pkg/mod/github.com/go-rod/rod@v0.105.1/must.go:70 +0xd3
main.screenshot({0x6f1ccf, 0x17}, {0xc0000c8000, 0x49}) ...

How can I make rod ignore the SSL certificate check?

@breezemight breezemight added the question Questions related to rod label Apr 14, 2022
@rod-robot
Copy link

Please add a valid **Rod Version:** v0.0.0 to your issue. Current version is v0.105.1
generated by check-issue

@ysmood
Copy link
Member

ysmood commented Apr 14, 2022

#322

@ysmood ysmood closed this as completed Apr 14, 2022
@breezemight
Copy link
Author

thanks

@breezemight breezemight changed the title Concurrent screenshotting fails after running for a while Screenshotting URLs with bad TLS certificates fails Apr 14, 2022
@breezemight breezemight changed the title Screenshotting URLs with bad TLS certificates fails Screenshotting URLs with bad TLS certificates fail Apr 14, 2022
@breezemight
Copy link
Author

@go-rog/everyone

@ysmood
Copy link
Member

ysmood commented Apr 14, 2022

Browser.IgnoreCertErrors

@ysmood ysmood reopened this Apr 14, 2022
@ysmood ysmood closed this as completed Apr 14, 2022
@breezemight
Copy link
Author

breezemight commented Apr 14, 2022

I changed the first block of main function with this :

buf, err := rod.New().ControlURL(u).MustConnect().Timeout(30 * time.Second).MustIgnoreCertErrors(true).MustPage(uri).
	MustWaitLoad().Screenshot(true, &proto.PageCaptureScreenshot{
	Format:  proto.PageCaptureScreenshotFormatJpeg,
	Quality: gson.Int(90),
})

now most of the urls with bad ssl are being screenshot. However a new but similar error appeared :

panic: navigation failed: net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH

@ysmood ysmood changed the title Screenshotting URLs with bad TLS certificates fail net::ERR_CONNECTION_CLOSED net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH Apr 14, 2022
@ysmood ysmood reopened this Apr 14, 2022
@ysmood
Copy link
Member

ysmood commented Apr 14, 2022

Then you can manually ignore this err, read the doc:

https://go-rod.github.io/#/error-handling

@breezemight
Copy link
Author

I'm already catching the error above but these errors will directly panic instead, making the err variable above completely useless. Totally not a design flaw or anything.
here's another brand new error :

panic: context deadline exceeded

I'm so done.

@ysmood
Copy link
Member

ysmood commented Apr 14, 2022

why not use the rod.Try?

panic: context deadline exceeded is the context.DeadlineExceeded, if you read the doc, you should know it. Your code has .Timeout(30 * time.Second) which will cause this error.

If you don't want to panic, you should use non-Must prefixed functions, please read the doc: https://go-rod.github.io/#/error-handling?id=error-handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

3 participants