소스 검색

修复证书重载逻辑并更新.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() {