Explorar el Código

refactor(sslcert): 优化 SSL 证书编辑逻辑

- 在 EditSSLCert 函数中增加判断,当 CertData 和 KeyData 都为空时,直接返回 nil
- 添加注释,说明证书解析步骤
fusu hace 3 semanas
padre
commit
79b357d303
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      internal/service/sslcert.go

+ 4 - 0
internal/service/sslcert.go

@@ -207,6 +207,10 @@ func (s *sslCertService) AddSSLCert(ctx context.Context, req v1.SSL) (int64, err
 
 
 func (s *sslCertService) EditSSLCert(ctx context.Context, req v1.SSL) error {
+	if req.CertData == "" && req.KeyData == "" {
+		return nil
+	}
+	// 1. 解析证书文件,提取元数据
 	serverName, commonNames, DNSNames, before, after, isSelfSigned, err := s.ParseCert(ctx, req.CertData, req.KeyData)
 	if err != nil {
 		return fmt.Errorf("解析证书失败: %w", err)