From 3303d77dad3b39cd15f5545e92a700361d026166 Mon Sep 17 00:00:00 2001
From: Simon Zolin <s.zolin@adguard.com>
Date: Wed, 18 Mar 2020 15:18:15 +0300
Subject: [PATCH] Merge: - tls: allow_unencrypted_doh and strict_sni_check
 settings were reset after POST /control/tls/configure Close #1484

Squashed commit of the following:

commit 2daae88b80d83889238eaf4808b8a4da4fd8b102
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Wed Mar 18 13:16:23 2020 +0300

    minor

commit 99fa4e27ad45e515c8faef14a77304c2a9687875
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Tue Mar 17 13:46:46 2020 +0300

    - tls: allow_unencrypted_doh and strict_sni_check settings were reset after POST /control/tls/configure
---
 home/tls.go | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/home/tls.go b/home/tls.go
index 317e7dd8..d5836a31 100644
--- a/home/tls.go
+++ b/home/tls.go
@@ -253,7 +253,18 @@ func (t *TLSMod) handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
 		log.Printf("tls config settings have changed, will restart HTTPS server")
 		restartHTTPS = true
 	}
-	t.conf = data
+	// Note: don't do just `t.conf = data` because we must preserve all other members of t.conf
+	t.conf.Enabled = data.Enabled
+	t.conf.ServerName = data.ServerName
+	t.conf.ForceHTTPS = data.ForceHTTPS
+	t.conf.PortHTTPS = data.PortHTTPS
+	t.conf.PortDNSOverTLS = data.PortDNSOverTLS
+	t.conf.CertificateChain = data.CertificateChain
+	t.conf.CertificatePath = data.CertificatePath
+	t.conf.CertificateChainData = data.CertificateChainData
+	t.conf.PrivateKey = data.PrivateKey
+	t.conf.PrivateKeyPath = data.PrivateKeyPath
+	t.conf.PrivateKeyData = data.PrivateKeyData
 	t.status = status
 	t.confLock.Unlock()
 	t.setCertFileTime()