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

Don't use Serve! Please use ServeTLS or ListenAndServeTLS #8

Closed
bddjr opened this issue Dec 4, 2024 · 1 comment
Closed

Don't use Serve! Please use ServeTLS or ListenAndServeTLS #8

bddjr opened this issue Dec 4, 2024 · 1 comment

Comments

@bddjr
Copy link
Owner

bddjr commented Dec 4, 2024

Don't use Serve like this:

// Use hlfhr.New
srv := hlfhr.New(&http.Server{
	TLSConfig: &tls.Config{
		GetCertificate: func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {
			// Write something...
		},
	},
})
// Then just use it like [http.Server]

l, err := net.Listen("tcp", addr)
if err != nil {
	return err
}
defer l.Close()

l = tls.NewListener(l, config)
srv.Serve(l)

✅ Please use ServeTLS:

// Use hlfhr.New
srv := hlfhr.New(&http.Server{
	TLSConfig: &tls.Config{
		GetCertificate: func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {
			// Write something...
		},
	},
})
// Then just use it like [http.Server]

l, err := net.Listen("tcp", ":5678")
if err != nil {
	return err
}
defer l.Close()

srv.ServeTLS("", "")

✅ or use ListenAndServeTLS

// Use hlfhr.New
srv := hlfhr.New(&http.Server{
	Addr: ":5678",
	TLSConfig: &tls.Config{
		GetCertificate: func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {
			// Write something...
		},
	},
})
// Then just use it like [http.Server]

srv.ListenAndServeTLS("", "")
@bddjr bddjr pinned this issue Dec 4, 2024
@bddjr bddjr closed this as completed Dec 4, 2024
@bddjr
Copy link
Owner Author

bddjr commented Dec 4, 2024

For issue #4

Repository owner locked and limited conversation to collaborators Dec 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant