浏览代码

fix: auto cert nil ptr issue

Jacky 1 年之前
父节点
当前提交
c18f8f0b27
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      internal/cert/auto_cert.go

+ 6 - 3
internal/cert/auto_cert.go

@@ -75,14 +75,17 @@ func autoCert(certModel *model.Cert) {
 		ChallengeMethod: certModel.ChallengeMethod,
 		ChallengeMethod: certModel.ChallengeMethod,
 		DNSCredentialID: certModel.DnsCredentialID,
 		DNSCredentialID: certModel.DnsCredentialID,
 		KeyType:         certModel.GetKeyType(),
 		KeyType:         certModel.GetKeyType(),
-		Resource: &model.CertificateResource{
+		NotBefore:       cert.NotBefore,
+	}
+
+	if certModel.Resource != nil {
+		payload.Resource = &model.CertificateResource{
 			Resource:          certModel.Resource.Resource,
 			Resource:          certModel.Resource.Resource,
 			PrivateKey:        certModel.Resource.PrivateKey,
 			PrivateKey:        certModel.Resource.PrivateKey,
 			Certificate:       certModel.Resource.Certificate,
 			Certificate:       certModel.Resource.Certificate,
 			IssuerCertificate: certModel.Resource.IssuerCertificate,
 			IssuerCertificate: certModel.Resource.IssuerCertificate,
 			CSR:               certModel.Resource.CSR,
 			CSR:               certModel.Resource.CSR,
-		},
-		NotBefore: cert.NotBefore,
+		}
 	}
 	}
 
 
 	// errChan will be closed inside IssueCert
 	// errChan will be closed inside IssueCert