fixed tls ca
This commit is contained in:
parent
41027fa380
commit
59d44932a4
2 changed files with 3 additions and 14 deletions
|
|
@ -21,6 +21,7 @@ func ParseFile(file string) (cfg *Config, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
cfg = new(Config)
|
cfg = new(Config)
|
||||||
err = yaml.NewDecoder(f).Decode(cfg)
|
err = yaml.NewDecoder(f).Decode(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.giftfish.de/ston1th/vipman/pkg/config"
|
"git.giftfish.de/ston1th/vipman/pkg/config"
|
||||||
|
|
@ -25,23 +24,12 @@ func loadCertPool(file string) (p *x509.CertPool, err error) {
|
||||||
if file == "" {
|
if file == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f, err := os.Open(file)
|
buf, err := ioutil.ReadFile(file)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
buf, err := ioutil.ReadAll(f)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
certs, err := x509.ParseCertificates(buf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p = x509.NewCertPool()
|
p = x509.NewCertPool()
|
||||||
for _, c := range certs {
|
p.AppendCertsFromPEM(buf)
|
||||||
p.AddCert(c)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue