瀏覽代碼

修复证书重载逻辑并更新.gitignore

修正了httpsslserver中证书重载的处理逻辑,确保在错误情况下正确关闭通道。同时,在.gitignore文件中添加了对go-remote.sh脚本的忽略。
SongZihuan 2 月之前
父節點
當前提交
5928cedb87
共有 2 個文件被更改,包括 5 次插入6 次删除
  1. 3 1
      .gitignore
  2. 2 5
      src/httpsslserver/server.go

+ 3 - 1
.gitignore

@@ -15,4 +15,6 @@ pkg
 http-demo
 .htaccess
 
-*.bak
+*.bak
+
+go-remote.sh

+ 2 - 5
src/httpsslserver/server.go

@@ -189,17 +189,14 @@ func watchCertificate(stopchan chan bool) {
 	}()
 
 	go func() {
-		close(newCertChan)
+		defer close(newCertChan)
 
 		for {
 			select {
 			case <-stopchan:
 				return
 			case res := <-newCertChan:
-				if res.Certificate == nil && res.PrivateKey == nil && res.Error == nil {
-					close(newCertChan)
-					return
-				} else if res.Error != nil {
+				if res.Error != nil {
 					fmt.Printf("https cert reload server error: %s", res.Error.Error())
 				} else if res.PrivateKey != nil && res.Certificate != nil && res.IssuerCertificate != nil {
 					func() {