/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
|
||||
|
||||
// prepare cert for HTTPS server
|
||||
cert, err := tls.X509KeyPair([]byte(config.TLS.CertificateChain), []byte(config.TLS.PrivateKey))
|
||||
// prepare certs for HTTPS server
|
||||
// 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 {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Reference in New Issue