divinity666 / ruby-grafana-reporter

Reporting Service for Grafana
MIT License
66 stars 5 forks source link

run ruby-grafana-reporter in win10, get a SSL error #33

Closed kazu12 closed 5 months ago

kazu12 commented 1 year ago

I use ruby-grafana-reporter v0.6.2.5, after config every thing, when I want create demo report, I get a SSL error:

D:\report>ruby-grafana-reporter-0.6.2_5.exe -t demo_report -o demo_report.pdf
I, [2022-10-17T20:41:21.233826 #17048]  INFO -- : Report started at 2022-10-17 20:41:21 +0800
I, [2022-10-17T20:41:21.235873 #17048]  INFO -- : You are running ruby-grafana-reporter version 0.6.2.
I, [2022-10-17T20:41:32.356738 #17048]  INFO -- : Report creation ended after 11 seconds with status 'died'
SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)
Z:/TEMP/ocrEED6.tmp/lib/ruby/2.7.0/net/protocol.rb:44:in `connect_nonblock'
Z:/TEMP/ocrEED6.tmp/lib/ruby/2.7.0/net/protocol.rb:44:in `ssl_socket_connect'
Z:/TEMP/ocrEED6.tmp/lib/ruby/2.7.0/net/http.rb:1009:in `connect'
Z:/TEMP/ocrEED6.tmp/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
Z:/TEMP/ocrEED6.tmp/lib/ruby/2.7.0/net/http.rb:932:in `start'
Z:/TEMP/ocrEED6.tmp/lib/ruby/2.7.0/net/http.rb:1483:in `request'
Z:/TEMP/ocrEED6.tmp/src/lib/grafana/webrequest.rb:51:in `execute'
Z:/TEMP/ocrEED6.tmp/src/lib/grafana_reporter/configuration.rb:174:in `latest_version_check_ok?'
Z:/TEMP/ocrEED6.tmp/src/lib/grafana_reporter/abstract_report.rb:147:in `create_report'
Z:/TEMP/ocrEED6.tmp/src/lib/grafana_reporter/application/application.rb:148:in `run'
Z:/TEMP/ocrEED6.tmp/src/lib/grafana_reporter/application/application.rb:120:in `configure_and_run'
Z:/TEMP/ocrEED6.tmp/src/bin/ruby-grafana-reporter:5:in `<main>'

what wrong with my setting or my env?

divinity666 commented 1 year ago

Hm. I just tried the reporter exe V0.6.2 against https://play.grafana.org, which worked perfectly fine.

Could it be, that you are running the reporter against a HTTPS grafana installation, which uses an unsigned and/or expired SSL certificate? Do you have the possibility to run your grafana setup with HTTP only to check, if it is working then?

kazu12 commented 1 year ago

sorry for replying delayed. I have run V0.6.2 again, it still got error. The error reason is 'certificate verify failed (unable to get local issuer certificate)'. My grafana didnot use ssl connect, an my env is win10 ltsc 2019. is it some way to bypass local certificate verify?

I, [2022-11-18T15:35:27.434127 #17912]  INFO -- : Server listening on port 8815...
E, [2022-11-18T15:36:14.978787 #17912] ERROR -- : GrafanaReporterError: Could not render report because of internal error: view_report has been called without valid id
I, [2022-11-18T15:37:02.612584 #17912]  INFO -- : 1 report(s) in progress: 0% (running 0 secs)
I, [2022-11-18T15:37:02.617462 #17912]  INFO -- : Report started at 2022-11-18 15:37:02 +0800
I, [2022-11-18T15:37:02.619117 #17912]  INFO -- : You are running ruby-grafana-reporter version 0.6.2.
I, [2022-11-18T15:37:02.677848 #17912]  INFO -- : Report creation ended after 0 seconds with status 'died'
Traceback (most recent call last):
        7: from Z:/TEMP/ocr8B24.tmp/src/bin/ruby-grafana-reporter:5:in `<main>'
        6: from Z:/TEMP/ocr8B24.tmp/src/lib/grafana_reporter/application/application.rb:120:in `configure_and_run'
        5: from Z:/TEMP/ocr8B24.tmp/src/lib/grafana_reporter/application/application.rb:154:in `run'
        4: from Z:/TEMP/ocr8B24.tmp/src/lib/grafana_reporter/application/webservice.rb:30:in `run'
        3: from Z:/TEMP/ocr8B24.tmp/src/lib/grafana_reporter/application/webservice.rb:62:in `accept_requests_loop'
        2: from Z:/TEMP/ocr8B24.tmp/src/lib/grafana_reporter/application/webservice.rb:62:in `loop'
        1: from Z:/TEMP/ocr8B24.tmp/src/lib/grafana_reporter/application/webservice.rb:77:in `block in accept_requests_loop'
Z:/TEMP/ocr8B24.tmp/src/lib/grafana_reporter/application/webservice.rb:77:in `readline': An existing connection was forcibly closed by the remote host. @ io_fillbuf - fd:4  (Errno::ECONNRESET)
divinity666 commented 1 year ago

What is the address of your grafana installation? I guess it starts with https. If so, the reporter expects that SSL is being used and tries to verify the certificate (this is currently hardcoded behavior).

If possible, you might try to expose your grafana installation with http only. Then it should work immediately. But keep in mind, that this might be a security issue.

If you stick to https currently the only solution would be to have a SSL certificate in your grafana server, which is NOT self-signed, but signed by a CA.

Maybe in a future version, I might consider providing an option in the reporter configuration for grafana to also allow self-signed certificates.

kazu12 commented 1 year ago

grafana didn't us https, but it can only access through VPN. Is it someway to passthrough SSL check or import some CA change certificate?

divinity666 commented 1 year ago

1) Could you please try to run a demo report in your environment against https://play.grafana.org, to see if this basically working in your environment? 2) Your second log seems strange to me. Obviously some communication between the browser and your client broke. Refer also here: https://stackoverflow.com/questions/2582036/an-existing-connection-was-forcibly-closed-by-the-remote-host. How can you reproduce this second error? 3) The reporter currently forces the SSL verification only if the grafana URL starts with https. If this is not the case in your environment, I would need further information about the complete setup. Anyway, I can't promise that we find the issue here. Maybe let's start with 1) and 2) before.

divinity666 commented 5 months ago

Closing because of missing feedback