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

Certificate and CA management is broken #1200

Closed
prydin opened this issue Aug 14, 2018 · 7 comments
Closed

Certificate and CA management is broken #1200

prydin opened this issue Aug 14, 2018 · 7 comments

Comments

@prydin
Copy link
Contributor

prydin commented Aug 14, 2018

It doesn't seem to be possible to set certificates and custom CAs on a Client, since they require an existing client and vim25.NewClient, as well as govmomi.NewClient send traffic through the client.

Here's the smoking gun:

c.ServiceContent, err = methods.GetServiceContent(ctx, rt)

GetServiceContent is called on the connection, which causes traffic to be sent across the transport. If the CA chain is not set up and the server presents a certificate from a private CA, the call will fail and the client never gets connected.

Suggested solution: Remove SetRootCAs et al and allow callers to NewClient to pass a TLSConfig instead. To preserve backward compatibility, we may want to introduce a NewClientWithTLSConfig instead.

@dougm
Copy link
Member

dougm commented Aug 14, 2018

SetRootCAs is a soap.Client method. You just need to configure the soap.Client before calling vim25.NewClient. Example:

	soapClient := soap.NewClient(u, false)
	err = soapClient.SetRootCAs("/path/to/file")
	if err != nil {
		log.Fatal(err)
	}

	vim25Client, err := vim25.NewClient(ctx, soapClient)
	if err != nil {
		log.Fatal(err)
	}

@prydin
Copy link
Contributor Author

prydin commented Aug 14, 2018

So I can't use govmomi.NewClient() if I want to specify a custom CA chain? I'd like to avoid having to use the lower level functions if possible. govmomi.NewClient() creates both the vim25 client and the soap client without any chance of intervening.

What do you think of the idea of letting callers pass a TLSConfiguration? It would work as a catch-all for any TLS customization a caller would like to make. I can issue a PR if there's interest.

@prydin
Copy link
Contributor Author

prydin commented Aug 14, 2018

From govmomi.NewClient. After line 80, it's too late to set up any CA chain, since the connection would already have failed.

govmomi/client.go

Lines 80 to 85 in 5bb443a

vimClient, err := vim25.NewClient(ctx, soapClient)
if err != nil {
return nil, err
}
c := &Client{

@dougm
Copy link
Member

dougm commented Aug 15, 2018

I'd prefer to deprecate govmomi.Client than to change it, as it only provides a handful of shortcuts. We probably should have a long time ago. If you look at the git history you'll see how it was pruned back and we moved to using vim25.Client instead in govc. There are a number of other config options, authentication methods, etc., that govmomi.NewClient doesn't support.

@prydin
Copy link
Contributor Author

prydin commented Aug 15, 2018

Not that you asked for my opinion, but I'll give it anyway.... :) I think removing govmomi.client would be a mistake. It's better to hide the implementation details from the caller. But that's just my opinion...

Could we still consider adding a soap.NewClientWithTLSConfig()? There are tons of configurable things, like ciphers, on a TLS connection and adding this function would provide a simple way of configuring the connection without adding tons methods on the client. Just a thought.

@prydin
Copy link
Contributor Author

prydin commented Aug 21, 2018

This behavior seems to be by design and a functioning workaround to my issue has been provided. I'm closing this.

@prydin prydin closed this as completed Aug 21, 2018
@dougm
Copy link
Member

dougm commented Aug 21, 2018

Meant to follow up on this.. we could improve the doc at least. I hesitate to add more methods to govmomi.Client as there are a number of other config options, auth methods, RoundTrip wrappers (retry, keepalive), etc., that need to happen in between soap.NewClient and vim25.NewClient.

djaglowski added a commit to open-telemetry/opentelemetry-collector-contrib that referenced this issue Dec 3, 2024
…ent call (#36482)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The `govmomi` client used in the receiver attempts to validate the
connection to vcenter before the existing code sets the TLS options
(other than insecure) in the client. This is a limitation of the
`govmomi` wrapper, as discussed on this issue:
vmware/govmomi#1200 .

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related issue in Grafana Alloy:
grafana/alloy#193

<!--Describe what testing was performed and which tests were added.-->
#### Testing
~~This has not been tested, I would appreciate the assistance of any
codeowner that could test.~~ See comments on the PR for test.

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
shivanthzen pushed a commit to shivanthzen/opentelemetry-collector-contrib that referenced this issue Dec 5, 2024
…ent call (open-telemetry#36482)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The `govmomi` client used in the receiver attempts to validate the
connection to vcenter before the existing code sets the TLS options
(other than insecure) in the client. This is a limitation of the
`govmomi` wrapper, as discussed on this issue:
vmware/govmomi#1200 .

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related issue in Grafana Alloy:
grafana/alloy#193

<!--Describe what testing was performed and which tests were added.-->
#### Testing
~~This has not been tested, I would appreciate the assistance of any
codeowner that could test.~~ See comments on the PR for test.

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
ZenoCC-Peng pushed a commit to ZenoCC-Peng/opentelemetry-collector-contrib that referenced this issue Dec 6, 2024
…ent call (open-telemetry#36482)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The `govmomi` client used in the receiver attempts to validate the
connection to vcenter before the existing code sets the TLS options
(other than insecure) in the client. This is a limitation of the
`govmomi` wrapper, as discussed on this issue:
vmware/govmomi#1200 .

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related issue in Grafana Alloy:
grafana/alloy#193

<!--Describe what testing was performed and which tests were added.-->
#### Testing
~~This has not been tested, I would appreciate the assistance of any
codeowner that could test.~~ See comments on the PR for test.

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this issue Dec 17, 2024
…ent call (open-telemetry#36482)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The `govmomi` client used in the receiver attempts to validate the
connection to vcenter before the existing code sets the TLS options
(other than insecure) in the client. This is a limitation of the
`govmomi` wrapper, as discussed on this issue:
vmware/govmomi#1200 .

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related issue in Grafana Alloy:
grafana/alloy#193

<!--Describe what testing was performed and which tests were added.-->
#### Testing
~~This has not been tested, I would appreciate the assistance of any
codeowner that could test.~~ See comments on the PR for test.

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
AkhigbeEromo pushed a commit to sematext/opentelemetry-collector-contrib that referenced this issue Jan 13, 2025
…ent call (open-telemetry#36482)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The `govmomi` client used in the receiver attempts to validate the
connection to vcenter before the existing code sets the TLS options
(other than insecure) in the client. This is a limitation of the
`govmomi` wrapper, as discussed on this issue:
vmware/govmomi#1200 .

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related issue in Grafana Alloy:
grafana/alloy#193

<!--Describe what testing was performed and which tests were added.-->
#### Testing
~~This has not been tested, I would appreciate the assistance of any
codeowner that could test.~~ See comments on the PR for test.

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
chengchuanpeng pushed a commit to chengchuanpeng/opentelemetry-collector-contrib that referenced this issue Jan 26, 2025
…ent call (open-telemetry#36482)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The `govmomi` client used in the receiver attempts to validate the
connection to vcenter before the existing code sets the TLS options
(other than insecure) in the client. This is a limitation of the
`govmomi` wrapper, as discussed on this issue:
vmware/govmomi#1200 .

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related issue in Grafana Alloy:
grafana/alloy#193

<!--Describe what testing was performed and which tests were added.-->
#### Testing
~~This has not been tested, I would appreciate the assistance of any
codeowner that could test.~~ See comments on the PR for test.

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants