diff --git a/internal/workflow/engine/executor_bizapply.go b/internal/workflow/engine/executor_bizapply.go index ca314941b..e39152679 100644 --- a/internal/workflow/engine/executor_bizapply.go +++ b/internal/workflow/engine/executor_bizapply.go @@ -98,7 +98,7 @@ func (ne *bizApplyNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeExe } // 申请证书 - obtainResp, err := ne.executeObtain(execCtx, &nodeCfg, lastCertificate) + obtainResp, err := ne.execObtainCertificate(execCtx, &nodeCfg, lastCertificate) if err != nil { return execRes, err } @@ -228,7 +228,7 @@ func (ne *bizApplyNodeExecutor) checkCanSkip(execCtx *NodeExecutionContext, last return false, "" } -func (ne *bizApplyNodeExecutor) executeObtain(execCtx *NodeExecutionContext, nodeCfg *domain.WorkflowNodeConfigForBizApply, lastCertificate *domain.Certificate) (*certacme.ObtainCertificateResponse, error) { +func (ne *bizApplyNodeExecutor) execObtainCertificate(execCtx *NodeExecutionContext, nodeCfg *domain.WorkflowNodeConfigForBizApply, lastCertificate *domain.Certificate) (*certacme.ObtainCertificateResponse, error) { // 读取私钥算法 // 如果复用私钥,则保持算法一致 keyAlgorithm := domain.CertificateKeyAlgorithmType(nodeCfg.KeyAlgorithm) diff --git a/internal/workflow/engine/executor_bizmonitor.go b/internal/workflow/engine/executor_bizmonitor.go index d3926ecce..e902a2c46 100644 --- a/internal/workflow/engine/executor_bizmonitor.go +++ b/internal/workflow/engine/executor_bizmonitor.go @@ -68,7 +68,7 @@ func (ne *bizMonitorNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeE } } - certs, err = ne.tryRetrievePeerCertificates(execCtx, targetAddr, targetDomain, nodeCfg.RequestPath) + certs, err = ne.execRetrieveCertificates(execCtx, targetAddr, targetDomain, nodeCfg.RequestPath) if err == nil { break } @@ -119,7 +119,7 @@ func (ne *bizMonitorNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeE return execRes, nil } -func (ne *bizMonitorNodeExecutor) tryRetrievePeerCertificates(execCtx *NodeExecutionContext, addr, domain, requestPath string) ([]*x509.Certificate, error) { +func (ne *bizMonitorNodeExecutor) execRetrieveCertificates(execCtx *NodeExecutionContext, addr, domain, requestPath string) ([]*x509.Certificate, error) { transport := xhttp.NewDefaultTransport() transport.DisableKeepAlives = true transport.TLSClientConfig = xtls.NewInsecureConfig() diff --git a/internal/workflow/engine/executor_bizupload.go b/internal/workflow/engine/executor_bizupload.go index 4f5007ba2..8bdf41f1c 100644 --- a/internal/workflow/engine/executor_bizupload.go +++ b/internal/workflow/engine/executor_bizupload.go @@ -132,6 +132,14 @@ func (ne *bizUploadNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeEx return execRes, fmt.Errorf("unsupported upload source: '%s'", nodeCfg.Source) } + // 二次检测是否可以跳过执行 + if lastCertificate != nil { + if xcert.EqualCertificatesFromPEM(certPEM, lastCertificate.Certificate) { + ne.logger.Info("skip this uploading, because the last uploaded certificate already exists") + return execRes, nil + } + } + // 验证证书 certX509, err := xcert.ParseCertificateFromPEM(certPEM) if err != nil { @@ -143,7 +151,7 @@ func (ne *bizUploadNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeEx // 验证私钥 privkey, err := xcert.ParsePrivateKeyFromPEM(privkeyPEM) if err != nil { - return nil, err + return execRes, err } else { matched := false switch pub := certX509.PublicKey.(type) { @@ -165,14 +173,6 @@ func (ne *bizUploadNodeExecutor) Execute(execCtx *NodeExecutionContext) (*NodeEx } } - // 二次检测是否可以跳过执行 - if lastCertificate != nil { - if xcert.EqualCertificatesFromPEM(certPEM, lastCertificate.Certificate) { - ne.logger.Info("skip this uploading, because the last uploaded certificate already exists") - return execRes, nil - } - } - // 保存证书实体 certificate := &domain.Certificate{ Source: domain.CertificateSourceTypeUpload,