add skip_tls_verify option for exchange rates
This commit is contained in:
@@ -200,3 +200,6 @@ data_source = euro_central_bank
|
|||||||
|
|
||||||
# Requesting exchange rates data timeout (0 - 4294967295 milliseconds), default is 10000 (10 seconds)
|
# Requesting exchange rates data timeout (0 - 4294967295 milliseconds), default is 10000 (10 seconds)
|
||||||
request_timeout = 10000
|
request_timeout = 10000
|
||||||
|
|
||||||
|
# Set to true skip tls verification when request exchange rates data
|
||||||
|
skip_tls_verify = false
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -32,8 +33,17 @@ func (a *ExchangeRatesApi) LatestExchangeRateHandler(c *core.Context) (interface
|
|||||||
|
|
||||||
uid := c.GetCurrentUid()
|
uid := c.GetCurrentUid()
|
||||||
|
|
||||||
|
transport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
|
||||||
|
if settings.Container.Current.ExchangeRatesSkipTLSVerify {
|
||||||
|
transport.TLSClientConfig = &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: time.Duration(settings.Container.Current.ExchangeRatesRequestTimeout) * time.Millisecond,
|
Transport: transport,
|
||||||
|
Timeout: time.Duration(settings.Container.Current.ExchangeRatesRequestTimeout) * time.Millisecond,
|
||||||
}
|
}
|
||||||
|
|
||||||
urls := dataSource.GetRequestUrls()
|
urls := dataSource.GetRequestUrls()
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ type Config struct {
|
|||||||
// Exchange Rates
|
// Exchange Rates
|
||||||
ExchangeRatesDataSource string
|
ExchangeRatesDataSource string
|
||||||
ExchangeRatesRequestTimeout uint32
|
ExchangeRatesRequestTimeout uint32
|
||||||
|
ExchangeRatesSkipTLSVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfiguration loads setting config from given config file path
|
// LoadConfiguration loads setting config from given config file path
|
||||||
@@ -590,6 +591,7 @@ func loadExchangeRatesConfiguration(config *Config, configFile *ini.File, sectio
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.ExchangeRatesRequestTimeout = getConfigItemUint32Value(configFile, sectionName, "request_timeout", defaultExchangeRatesDataRequestTimeout)
|
config.ExchangeRatesRequestTimeout = getConfigItemUint32Value(configFile, sectionName, "request_timeout", defaultExchangeRatesDataRequestTimeout)
|
||||||
|
config.ExchangeRatesSkipTLSVerify = getConfigItemBoolValue(configFile, sectionName, "skip_tls_verify", false)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user