Skip to content

Commit

Permalink
Add option to skip verification of ssl certificates
Browse files Browse the repository at this point in the history
Some environments uses internal certificates and some IOT devices have limited to no root certificates
causing verification of ssl certificates to become problematic.
  • Loading branch information
jengell committed Jan 22, 2024
1 parent a5fa5ec commit 7075a11
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ By default, GoDNS uses `JSON` config file. However, you can specify to use the `
- `interval` — How often (in seconds) the public IP should be updated.
- `socks5_proxy` — Socks5 proxy server.
- `resolver` — Address of a public DNS server to use. For instance to use [Google's public DNS](https://developers.google.com/speed/public-dns/docs/using), you can set `8.8.8.8` when using GoDNS in IPv4 mode or `2001:4860:4860::8888` in IPv6 mode.
- `skip_ssl_verify` - Skip verification of ssl certificates for https requests.
### Update root domain
Expand Down
1 change: 1 addition & 0 deletions configs/config_sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"use_proxy": false,
"debug_info": false,
"proxied": false,
"skip_ssl_verify": false,
"notify": {
"telegram": {
"enabled": false,
Expand Down
1 change: 1 addition & 0 deletions configs/config_sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ip_interface: eth0
socks5_proxy:
use_proxy: false
debug_info: false
skip_ssl_verify: false
notify:
telegram:
enabled: false
Expand Down
1 change: 1 addition & 0 deletions internal/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ type Settings struct {
AppKey string `json:"app_key" yaml:"app_key"`
AppSecret string `json:"app_secret" yaml:"app_secret"`
ConsumerKey string `json:"comsumer_key" yaml:"comsumer_key"`
SkipSSLVerify bool `json:"skip_ssl_verify" yaml:"skip_ssl_verify"`
}

// LoadSettings -- Load settings from config file.
Expand Down
10 changes: 9 additions & 1 deletion internal/utils/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"context"
"crypto/tls"
"net"
"net/http"
"time"
Expand Down Expand Up @@ -31,9 +32,16 @@ func GetHTTPClient(conf *settings.Settings) *http.Client {
return dialer.Dial(network, address)
}

httpTransport := &http.Transport{}
httpTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: conf.SkipSSLVerify},
}
client.Transport = httpTransport
httpTransport.DialContext = dialContext
} else {
httpTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: conf.SkipSSLVerify},
}
client.Transport = httpTransport
}

return client
Expand Down

0 comments on commit 7075a11

Please sign in to comment.