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

Serve webhook server on https #627

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,20 +924,16 @@ func (p *Proxy) listenWSS(addr string) (net.Listener, error) {

func (p *Proxy) listenBroflake(baseListen func(string) (net.Listener, error)) listenerBuilderFN {
return func(addr string) (net.Listener, error) {
l, err := net.Listen("tcp", addr)
if err != nil {
return nil, err
}
certPEM, _ := os.ReadFile(p.CertFile)
keyPEM, _ := os.ReadFile(p.KeyFile)
cert, _ := tls.X509KeyPair(certPEM, keyPEM)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some error verifications? If the cert file or Key file are empty we probably need to decide what to do.

  1. We can return an error informing about the missing parameters for this proxy
  2. We could ignore these errors and not build a TLS config (but we probably don't want that)

Copy link
Contributor Author

@AGMETEOR AGMETEOR Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to take care of those. I just wanted to confirm that indeed this is the right path to the fix


certPEM, err := os.ReadFile(p.CertFile)
if err != nil {
log.Fatalf("Unable to read certificate file: %v", err)
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
MaxVersion: tls.VersionTLS12,
}

keyPEM, err := os.ReadFile(p.KeyFile)
if err != nil {
log.Fatalf("Unable to read key file: %v", err)
}
l, _ := tls.Listen("tcp", addr, tlsConfig)

wrapped, wrapErr := broflake.Wrap(l, string(certPEM), string(keyPEM))
if wrapErr != nil {
Expand Down
Loading