From 2c5ed10d60793afac9dffeae269b68ad5026acbb Mon Sep 17 00:00:00 2001 From: Mariano Cano <mariano@smallstep.com> Date: Tue, 5 Feb 2019 13:44:24 -0800 Subject: [PATCH] Use certificate common name as default prefix. --- truststore.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/truststore.go b/truststore.go index d70efca..714af03 100644 --- a/truststore.go +++ b/truststore.go @@ -12,7 +12,7 @@ import ( "os" ) -var prefix = "Truststore Development CA " +var prefix = "" var enableDebug bool func debug(format string, args ...interface{}) { @@ -214,7 +214,14 @@ func WithPrefix(s string) Option { } func uniqueName(cert *x509.Certificate) string { - return prefix + cert.SerialNumber.String() + switch { + case prefix != "": + return prefix + cert.SerialNumber.String() + case cert.Subject.CommonName != "": + return cert.Subject.CommonName + " " + cert.SerialNumber.String() + default: + return "Truststore Development CA " + cert.SerialNumber.String() + } } func saveTempCert(cert *x509.Certificate) (string, func(), error) { -- GitLab