zabbix-tools / go-zabbix

Go bindings for the Zabbix API
GNU General Public License v2.0
108 stars 70 forks source link

Example of Zabbix API calls with enabled HTTPS #23

Closed mikhels closed 5 years ago

mikhels commented 5 years ago

Hello,

Recently we enabled https on our zabbix server and after that I cannot make api calls work using go-zabbix library. Could you point me how it can be done, maybe some examples?

Now I'm getting the error:

Post : unsupported protocol scheme ""
cavaliercoder commented 5 years ago

The URL you pass to this package is passed directly to the Go HTTP client. You should simply prepend https:// to the URL and everything should work. Please advise if this is not the case.

mikhels commented 5 years ago

Hello,

First of all, thank you for the library, it's really helpful!

After your comment I investigated the problem a bit more more and discovered that go https client doesn't recognize that the server's certificate is valid. So a workaround was pretty easy:

http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

I'll continue to investigate why the certificate isn't considered as valid but that's definitely not a go-zabbix issue.

Thank you for help!