Fetch caBundlePath from environment variable

This commit is contained in:
Arturo Filastò 2018-05-11 16:06:28 +02:00
parent b8a0cc509c
commit d15fddc538

View File

@ -3,6 +3,7 @@ package nettests
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os"
"path/filepath" "path/filepath"
"github.com/apex/log" "github.com/apex/log"
@ -42,6 +43,14 @@ type Controller struct {
msmtPath string // XXX maybe we can drop this and just use a temporary file msmtPath string // XXX maybe we can drop this and just use a temporary file
} }
func getCaBundlePath() {
path := os.Getenv("SSL_CERT_FILE")
if path != "" {
return path
}
return "/etc/ssl/cert.pem"
}
// Init should be called once to initialise the nettest // Init should be called once to initialise the nettest
func (c *Controller) Init(nt *mk.Nettest) error { func (c *Controller) Init(nt *mk.Nettest) error {
log.Debugf("Init: %v", nt) log.Debugf("Init: %v", nt)
@ -77,7 +86,7 @@ func (c *Controller) Init(nt *mk.Nettest) error {
GeoIPCountryPath: filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIP.dat"), GeoIPCountryPath: filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIP.dat"),
GeoIPASNPath: filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIPASNum.dat"), GeoIPASNPath: filepath.Join(utils.GeoIPDir(c.Ctx.Home), "GeoIPASNum.dat"),
OutputPath: c.msmtPath, OutputPath: c.msmtPath,
CaBundlePath: "/etc/ssl/cert.pem", CaBundlePath: getCaBundlePath(),
} }
nt.On("log", func(e mk.Event) { nt.On("log", func(e mk.Event) {