From 8360590f2a21c33935f926f0c4bec6cda5d1fc89 Mon Sep 17 00:00:00 2001 From: liuxinfeng Date: Wed, 13 Sep 2023 09:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=8F=91=E6=97=A5=E6=9C=9F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/certificate.go | 4 ++-- utils/certificate_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/certificate.go b/utils/certificate.go index d7149721..d58792cf 100644 --- a/utils/certificate.go +++ b/utils/certificate.go @@ -93,7 +93,7 @@ func GenerateCertificateSelf(privateKeyBytes, csrBytes []byte, template := &bcx509.Certificate{ SerialNumber: sn, NotBefore: notBefore, - NotAfter: notBefore.Add(365 * 10 * time.Hour * 24).UTC(), + NotAfter: notBefore.Add(time.Hour * 24 * time.Duration(days)).UTC(), BasicConstraintsValid: true, IsCA: true, KeyUsage: keyUsage, @@ -163,7 +163,7 @@ func GenerateCertificate(caCertBytes, caKeyBytes, csrBytes []byte, isCa bool, template := &bcx509.Certificate{ SerialNumber: sn, NotBefore: notBefore, - NotAfter: notBefore.Add(365 * 10 * time.Hour * 24).UTC(), + NotAfter: notBefore.Add(time.Hour * 24 * time.Duration(days)).UTC(), BasicConstraintsValid: true, IsCA: isCa, KeyUsage: keyUsage, diff --git a/utils/certificate_test.go b/utils/certificate_test.go index 11bc83d2..0082e8e4 100644 --- a/utils/certificate_test.go +++ b/utils/certificate_test.go @@ -71,7 +71,7 @@ func TestCreateCertificate(t *testing.T) { csrBytes, err := GenerateCertificateSigningRequest(sk, "node", "node1") require.Nil(t, err) - certBytes, err := GenerateCertificate(caBytes, caSk, csrBytes, false, 365) + certBytes, err := GenerateCertificate(caBytes, caSk, csrBytes, false, 365*10) require.Nil(t, err) fmt.Println(string(certBytes))