Skip to content

Commit 2984b0d

Browse files
committed
feat: 增加修改密钥
1 parent 4edfdc4 commit 2984b0d

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

cert.go

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,8 @@ func initConfig() {
5656

5757
reader := bufio.NewReader(os.Stdin)
5858

59-
for {
60-
fmt.Print("请选择要配置的平台,目前支持certd、west,可以单一使用,也可混用,多个平台用空格分隔: ")
61-
thirdC, _ := reader.ReadString('\n')
62-
thirdC = strings.TrimSpace(thirdC)
63-
var thirdCs []string
64-
if thirdC != "" {
65-
thirdCs = strings.Split(thirdC, " ")
66-
}
67-
for _, t := range thirdCs {
68-
if t != "certd" && t != "west" {
69-
color.Red("平台错误,目前支持certd、west,多个平台用空格分隔")
70-
continue
71-
} else if t == "certd" {
72-
certd.SetConfig()
73-
} else if t == "west" {
74-
west.SetConfig()
75-
}
76-
}
77-
break
78-
}
59+
// 设置平台密钥
60+
modifyKey()
7961

8062
// 输入重载命令
8163
fmt.Printf("请输入重载命令(如: %s): ", defaultReloadCmd)
@@ -390,7 +372,7 @@ func showCertificates() error {
390372

391373
for {
392374
getCertificates()
393-
fmt.Println("请输入操作:1=添加、2=删除、4=修改重载命令、5=更新证书、6=修改提前更新天数、7=快速添加域名(Nginx目录检索)、9=查看配置信息、0=退出")
375+
fmt.Println("请输入操作:1=添加、2=删除、3=修改密钥、4=修改重载命令、5=更新证书、6=修改提前更新天数、7=快速添加域名(Nginx目录检索)、9=查看配置信息、0=退出")
394376
fmt.Print(">>> ")
395377
if scanner.Scan() {
396378
input := scanner.Text()
@@ -410,6 +392,9 @@ func showCertificates() error {
410392
return err
411393
}
412394
continue
395+
case "3":
396+
modifyKey()
397+
continue
413398
case "4": // 修改重载命令
414399
err := modifyRestartCmd()
415400
if err != nil {
@@ -704,6 +689,32 @@ func getConfigInfo() error {
704689
return err
705690
}
706691

692+
// 修改密钥
693+
func modifyKey() {
694+
reader := bufio.NewReader(os.Stdin)
695+
696+
for {
697+
fmt.Print("请选择要配置的平台,目前支持certd、west,可以单一使用,也可混用,多个平台用空格分隔: ")
698+
thirdC, _ := reader.ReadString('\n')
699+
thirdC = strings.TrimSpace(thirdC)
700+
var thirdCs []string
701+
if thirdC != "" {
702+
thirdCs = strings.Split(thirdC, " ")
703+
}
704+
for _, t := range thirdCs {
705+
if t != "certd" && t != "west" {
706+
color.Red("平台错误,目前支持certd、west,多个平台用空格分隔")
707+
continue
708+
} else if t == "certd" {
709+
certd.SetConfig()
710+
} else if t == "west" {
711+
west.SetConfig()
712+
}
713+
}
714+
break
715+
}
716+
}
717+
707718
// 检查是否初始化
708719
func checkInit() bool {
709720
isInit, err := config.GetConfig("", "is_init")

0 commit comments

Comments
 (0)