-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: Support HTTPS endpoints #1084
Conversation
ab9839c
to
5ccf512
Compare
When running as an app in CF we can rely on the platform to handle TLS setup, but on a VM currently there is no way to have encrypted traffic. TPCF-26820
5ccf512
to
290446f
Compare
it is angry about `.` imports. But we do not mind because this is not production code.
internal/testdrive/broker_start.go
Outdated
scheme := "http" | ||
for _, envVar := range cmd.Env { | ||
if strings.HasPrefix(envVar, "TLS_") { | ||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Avoid modifying the global http.DefaultTransport
directly. Instead, create a custom transport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for tests?
internal/testdrive/broker_start.go
Outdated
caBytes, err := x509.CreateCertificate(rand.Reader, ca, ca, &caPrivKey.PublicKey, caPrivKey) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
caPEM, _ := encodeKeyPair(caBytes, x509.MarshalPKCS1PrivateKey(caPrivKey)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (non-blocking): the PEM-encoded CA certificate is not being used. The code is not necessary, by removing it, we will improve the readability and the public API of the createCAKeyPair function
internal/testdrive/broker_start.go
Outdated
Expect(err).NotTo(HaveOccurred()) | ||
|
||
certPEM, certPrivKeyPEM := encodeKeyPair(certBytes, x509.MarshalPKCS1PrivateKey(certPrivKey)) | ||
return certPEM, certPrivKeyPEM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts: I prefer to declare the variable using value semantics and return it using pointer semantic. If the body of the functions grows, the readability gets worse.
return &certPEM, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand how the readability will get better by returning a pointer?
cmd/serve.go
Outdated
tlsKey := viper.GetString(tlsKeyProp) | ||
|
||
logger.Info("tlsCertCaBundle", lager.Data{"tlsCertCaBundle": tlsCertCaBundle}) | ||
logger.Info("tlsKey", lager.Data{"tlsKey": tlsKey}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: we want to avoid logging sensitive data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats a path
cmd/serve.go
Outdated
logger.Fatal("Failed to start broker", err) | ||
} | ||
} else { | ||
_ = httpServer.ListenAndServe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ = httpServer.ListenAndServe() | |
err := httpServer.ListenAndServe() | |
if err != nil { | |
logger.Fatal("Failed to start broker without TLS", err) | |
} |
Co-authored-by: Andrea Zucchini <[email protected]>
currently the broker.client is not embedding http client. It never needed to because the broker was written as a CF app and therefore never had to consider handling self signed certs. But since we are changing towards supporting VM based deployment, we need to think about how our test client will handle self signed certs. This seems to be the path of least resistance, by embedding an http client in the broker client struct, we can rely on setting the embedded clients transport config to allow for "insecure" connecions.
019ba01
to
172bcab
Compare
Checklist: