Skip to content
Snippets Groups Projects
Commit 2c5ed10d authored by Mariano Cano's avatar Mariano Cano
Browse files

Use certificate common name as default prefix.

parent 94e089c1
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
"os" "os"
) )
var prefix = "Truststore Development CA " var prefix = ""
var enableDebug bool var enableDebug bool
func debug(format string, args ...interface{}) { func debug(format string, args ...interface{}) {
...@@ -214,7 +214,14 @@ func WithPrefix(s string) Option { ...@@ -214,7 +214,14 @@ func WithPrefix(s string) Option {
} }
func uniqueName(cert *x509.Certificate) string { 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) { func saveTempCert(cert *x509.Certificate) (string, func(), error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment