Skip to content

Commit

Permalink
签发日期设置
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxinfeng96 committed Sep 13, 2023
1 parent 2805adf commit 8360590
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions utils/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion utils/certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8360590

Please sign in to comment.