/tls/ -- prevent encryption errors when changing certificates mid-request
This commit is contained in:
parent
0b7f0396de
commit
885e4e16c8
9
app.go
9
app.go
|
@ -185,8 +185,13 @@ func run(args options) {
|
||||||
}
|
}
|
||||||
config.TLS = data // update warnings
|
config.TLS = data // update warnings
|
||||||
|
|
||||||
// prepare cert for HTTPS server
|
// prepare certs for HTTPS server
|
||||||
cert, err := tls.X509KeyPair([]byte(config.TLS.CertificateChain), []byte(config.TLS.PrivateKey))
|
// important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests
|
||||||
|
certchain := make([]byte, len(config.TLS.CertificateChain))
|
||||||
|
copy(certchain, []byte(config.TLS.CertificateChain))
|
||||||
|
privatekey := make([]byte, len(config.TLS.PrivateKey))
|
||||||
|
copy(privatekey, []byte(config.TLS.PrivateKey))
|
||||||
|
cert, err := tls.X509KeyPair(certchain, privatekey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in New Issue