-
Notifications
You must be signed in to change notification settings - Fork 15
Support Self-Signed CA Cert and skip-cert-verify with Hub Client #210
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
Support Self-Signed CA Cert and skip-cert-verify with Hub Client #210
Conversation
7941050 to
2250ed3
Compare
2250ed3 to
adc517b
Compare
config/certs_test.go
Outdated
| assert.Nil(t, err) | ||
| assert.Equal(t, cert1, ctx) | ||
|
|
||
| ctx, err = GetCert("https://test1") |
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.
nit: This was already existing, but can we change the ctx to something so that it is more opt?
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.
+1
ctx->cert throughout would have made more sense.
prkalle
left a comment
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.
LGTM. I have a minor nit comment. Thanks
vuil
left a comment
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.
very nice!
Some nits and suggestion for additional test cases.
|
|
||
| // GetCert retrieves the cert configuration by host | ||
| func GetCert(host string) (*configtypes.Cert, error) { | ||
| if host == "" { |
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.
suggestion: update comment to say "by host or URI"
config/certs_test.go
Outdated
| assert.Nil(t, err) | ||
| assert.Equal(t, cert1, ctx) | ||
|
|
||
| ctx, err = GetCert("https://test1/fake") |
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.
suggestion: add 3 more cases for
ws://test1/fake and
wss://test1/fake to show this works for websocket URIs as well.
and
https://test1:12345/fake for custom port handling
| ctx, err = GetCert("https://test1/fake") | ||
| assert.Nil(t, err) | ||
| assert.Equal(t, cert1, ctx) | ||
|
|
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.
nit: suggest add another case of invalid uri
ctx, err = GetCert("https://tes t1/fak e") or something, should we choose to return a better error as suggested above.
| if host == "" { | ||
| return nil, errors.New("host is empty") | ||
| } | ||
| u, err := url.Parse(host) |
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.
an unparsable URI ends up getting the same error as a missing entry.
how about just return here,
with errors.New("invalid uri") or wrap the err?
|
another nit: |
450d083 to
c4dede5
Compare
vuil
left a comment
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.
lgtm, thanks
c4dede5 to
c3c2e33
Compare
…date to GetCert API (vmware-tanzu#210) * Support self-signed CA Cert and skip-cert-verify with Hub Client * GetCert API now accepts URI along with hostname
…date to GetCert API (#210) * Support self-signed CA Cert and skip-cert-verify with Hub Client * GetCert API now accepts URI along with hostname
What this PR does / why we need it
GetCertAPI to get the certificate data for the specified hub endpoint.Which issue(s) this PR fixes
Fixes #
Describe testing done for PR
Release note
Additional information
Special notes for your reviewer