Skip to content

Commit f4c068a

Browse files
committed
crypto: error message should use duration instead of years
1 parent 965d746 commit f4c068a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/crypto/crypto.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ func MakeSelfSignedCAConfig(name string, lifetime time.Duration) (*TLSCertificat
629629
func MakeSelfSignedCAConfigForSubject(subject pkix.Name, lifetime time.Duration) (*TLSCertificateConfig, error) {
630630
if lifetime <= 0 {
631631
lifetime = DefaultCACertificateLifetimeDuration
632-
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %d years!\n", subject.CommonName, lifetime)
632+
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %s!\n", subject.CommonName, lifetime.String())
633633
}
634634

635635
if lifetime > DefaultCACertificateLifetimeDuration {
@@ -1018,7 +1018,7 @@ func newSigningCertificateTemplateForDuration(subject pkix.Name, caLifetime time
10181018
func newServerCertificateTemplate(subject pkix.Name, hosts []string, lifetime time.Duration, currentTime func() time.Time, authorityKeyId, subjectKeyId []byte) *x509.Certificate {
10191019
if lifetime <= 0 {
10201020
lifetime = DefaultCertificateLifetimeDuration
1021-
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %d years!\n", subject.CommonName, lifetime)
1021+
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %s!\n", subject.CommonName, lifetime.String())
10221022
}
10231023

10241024
if lifetime > DefaultCertificateLifetimeDuration {
@@ -1105,7 +1105,7 @@ func CertsFromPEM(pemCerts []byte) ([]*x509.Certificate, error) {
11051105
func NewClientCertificateTemplate(subject pkix.Name, lifetime time.Duration, currentTime func() time.Time) *x509.Certificate {
11061106
if lifetime <= 0 {
11071107
lifetime = DefaultCertificateLifetimeDuration
1108-
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %d years!\n", subject.CommonName, lifetime)
1108+
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %s!\n", subject.CommonName, lifetime.String())
11091109
}
11101110

11111111
if lifetime > DefaultCertificateLifetimeDuration {

pkg/crypto/crypto_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func TestCrypto(t *testing.T) {
142142
func newSigningCertificateTemplate(subject pkix.Name, lifetime time.Duration, currentTime func() time.Time) *x509.Certificate {
143143
if lifetime <= 0 {
144144
lifetime = DefaultCACertificateLifetimeDuration
145-
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %d years!\n", subject.CommonName, lifetime)
145+
fmt.Fprintf(os.Stderr, "Validity period of the certificate for %q is unset, resetting to %s!\n", subject.CommonName, lifetime.String())
146146
}
147147

148148
if lifetime > DefaultCACertificateLifetimeDuration {

0 commit comments

Comments
 (0)