Skip to content

Conversation

@anujc25
Copy link
Contributor

@anujc25 anujc25 commented Aug 29, 2024

What this PR does / why we need it

  • The Hub Client will use the GetCert API to get the certificate data for the specified hub endpoint.
  • If the certificate data is not found, it will skip the TLS configuration and let the client use default configuration.
  • GetCert API now accepts URI along with hostname

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

Release note

Support Self-Signed CA Cert and skip-cert-verify with Hub Client
GetCert API now accepts URI along with hostname

Additional information

Special notes for your reviewer

@anujc25 anujc25 requested a review from a team as a code owner August 29, 2024 22:39
@anujc25 anujc25 force-pushed the support-self-signed-ca-with-hub-client branch from 7941050 to 2250ed3 Compare August 29, 2024 22:56
@anujc25 anujc25 force-pushed the support-self-signed-ca-with-hub-client branch from 2250ed3 to adc517b Compare August 29, 2024 22:57
assert.Nil(t, err)
assert.Equal(t, cert1, ctx)

ctx, err = GetCert("https://test1")
Copy link
Contributor

@prkalle prkalle Aug 29, 2024

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?

Copy link
Contributor

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.

Copy link
Contributor

@prkalle prkalle left a 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

Copy link
Contributor

@vuil vuil left a 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 == "" {
Copy link
Contributor

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"

assert.Nil(t, err)
assert.Equal(t, cert1, ctx)

ctx, err = GetCert("https://test1/fake")
Copy link
Contributor

@vuil vuil Aug 30, 2024

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)

Copy link
Contributor

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)
Copy link
Contributor

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?

@vuil
Copy link
Contributor

vuil commented Aug 30, 2024

another nit:
Maybe GetCert deserves a mention in docs/config.md?
Also mention in release notes GetCert is updated to accept URI.

@anujc25 anujc25 force-pushed the support-self-signed-ca-with-hub-client branch from 450d083 to c4dede5 Compare August 30, 2024 04:25
Copy link
Contributor

@vuil vuil left a comment

Choose a reason for hiding this comment

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

lgtm, thanks

@anujc25 anujc25 force-pushed the support-self-signed-ca-with-hub-client branch from c4dede5 to c3c2e33 Compare August 30, 2024 16:06
@anujc25 anujc25 merged commit f5842d0 into vmware-tanzu:main Aug 30, 2024
anujc25 added a commit to anujc25/tanzu-plugin-runtime that referenced this pull request Aug 30, 2024
…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
anujc25 added a commit that referenced this pull request Aug 30, 2024
…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
@marckhouzam marckhouzam added this to the v1.4.3 milestone Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants