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

Use workaround for windows x509.SystemCertPool() #2756

Merged
merged 6 commits into from
Feb 4, 2021
Merged

Use workaround for windows x509.SystemCertPool() #2756

merged 6 commits into from
Feb 4, 2021

Conversation

Ashmita152
Copy link
Contributor

Signed-off-by: Ashmita Bohara ashmita.bohara152@gmail.com

Which problem is this PR solving?

Fixes #2550

Short description of the changes

Doing exactly same as sensu/sensu-go#4018

@Ashmita152 Ashmita152 requested a review from a team as a code owner February 1, 2021 18:25
@codecov
Copy link

codecov bot commented Feb 1, 2021

Codecov Report

Merging #2756 (6db3693) into master (c7c371d) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2756      +/-   ##
==========================================
+ Coverage   95.84%   95.88%   +0.04%     
==========================================
  Files         217      218       +1     
  Lines        9625     9626       +1     
==========================================
+ Hits         9225     9230       +5     
+ Misses        330      327       -3     
+ Partials       70       69       -1     
Impacted Files Coverage Δ
pkg/config/tlscfg/certpool_unix.go 100.00% <100.00%> (ø)
pkg/config/tlscfg/options.go 100.00% <100.00%> (ø)
cmd/query/app/static_handler.go 95.16% <0.00%> (+0.80%) ⬆️
cmd/query/app/server.go 97.08% <0.00%> (+1.45%) ⬆️
cmd/collector/app/server/zipkin.go 76.92% <0.00%> (+3.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7c371d...931e764. Read the comment docs.

pkg/config/tlscfg/options_unix.go Outdated Show resolved Hide resolved
pkg/config/tlscfg/options.go Outdated Show resolved Hide resolved
@Ashmita152
Copy link
Contributor Author

Hi @yurishkuro

Being very new to golang, I am confused about what changes we need here, would be very helpful if you can guide me.

cmd/opentelemetry/go.sum Outdated Show resolved Hide resolved
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

So similar to how you split Windows and non-Windows logic in the new files, but you only implemented a narrow function there. I would start with L89

certPool, err := systemCertPool()

and basically implement this function differently in Win/Linux. Note that this is currently a pointer to a function, so the linux file will be simply

var systemCertPool = x509.SystemCertPool // to allow overriding in unit test

while in Windows file you can do whatever else is needed

Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
jpkrohling
jpkrohling previously approved these changes Feb 4, 2021
Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

A bit of cleanup

pkg/config/tlscfg/options.go Outdated Show resolved Hide resolved
pkg/config/tlscfg/options_unix.go Outdated Show resolved Hide resolved
pkg/config/tlscfg/options.go Outdated Show resolved Hide resolved
pkg/config/tlscfg/options_unix.go Outdated Show resolved Hide resolved
pkg/config/tlscfg/options_windows.go Outdated Show resolved Hide resolved
pkg/config/tlscfg/options_windows.go Outdated Show resolved Hide resolved
@mergify mergify bot dismissed jpkrohling’s stale review February 4, 2021 15:49

Pull request has been modified.

Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
@Ashmita152
Copy link
Contributor Author

Nice feedbacks Yuri. I can feel the redundant error checking I was doing before. Much cleaner now.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

thanks!

@yurishkuro yurishkuro merged commit 521e2a5 into jaegertracing:master Feb 4, 2021
@ghost
Copy link

ghost commented Apr 8, 2021

I'm running version 1.22.0 but I still get failed to load TLS config: failed to load CA CertPool: failed to load SystemCertPool: crypto/x509: system root pool is not available on Window. Specifying --reporter.grpc.tls.ca with an appropriate .pem file fixes it

@Ashmita152
Copy link
Contributor Author

Hi @roederja2

Thank you for reporting the issue. We will look into it.

@ghost
Copy link

ghost commented Apr 9, 2021

Thanks. For completeness these are my arguments to jaeger-agent:
Doesn't work:
--reporter.grpc.host-port=dns:///jaeger-collector:443 --reporter.grpc.tls.enabled=true --reporter.grpc.tls.skip-host-verify=true

works:
--reporter.grpc.host-port=dns:///jaeger-collector:443 --reporter.grpc.tls.enabled=true --reporter.grpc.tls.skip-host-verify=true --reporter.grpc.tls.ca=C:/Jaeger/ca-certs.pem

@DuckyC
Copy link

DuckyC commented May 10, 2021

I can confirm #2550 is still not fixed. I'm running the same arguments as @roederja2.
Maybe #2550 should be re-opened?

@yury-kozlov
Copy link

yury-kozlov commented May 28, 2021

I can confirm #2550 is still not fixed. I'm running the same arguments as @roederja2.
Maybe #2550 should be re-opened?

@DuckyC make sure you run agent with parameters:
--reporter.grpc.host-port=your-collector-host:your-collector-port,
--reporter.grpc.tls.enabled=true
--reporter.grpc.tls.ca=path-to-your-pem
with pem containing required certificate

I had troubles when running agent on Windows with additional arguments reporter.grpc.tls.cert and reporter.grpc.tls.key, but when I removed them and used only reporter.grpc.tls.enabled and reporter.grpc.tls.ca everything worked fine.

@DuckyC
Copy link

DuckyC commented May 28, 2021

Yeah, I ended up having to do that. But the CA is already trusted by the default certificate store in windows.
I had to download the LetsEncrypt CA and point it to that.

tmacam added a commit to tmacam/dapr-components-contrib that referenced this pull request Nov 30, 2022
Tests in vault_test.go had the following :

```go
    // This call will throw an error on Windows systems because of the of
    // the call x509.SystemCertPool() because system root pool is not
    // available on Windows so ignore the error for when the tests are run
    // on the Windows platform during CI
    _ = target.Init(m)
```

As of Go 1.18 this is not the case for Windows anymore and
we can instead enforce error checking. References:

* golang/go#16736
* golang/go#18609
* rancher/system-agent#84
* jaegertracing/jaeger#2756

Given Dapr depends on Go 1.19, we can enforce tests on `Init` result
and remove this comment.

While enforcing error checking we notice that the code above was
actually hiding errors in the test setup. Component initialization was
ending prematurely due to those errors and the test code was wrongfully
testing for the behavior of a component that has not been successfully
initialized. This is also addressed in this PR.

Closes dapr#2330.

Signed-off-by: Tiago Alves Macambira <tmacam@burocrata.org>
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

Successfully merging this pull request may close these issues.

jaeger-agent --reporter.grpc.tls.enabled=true fails on windows
5 participants