Mariano Cano 6 лет назад
Родитель
Сommit
3c84453cf4
2 измененных файлов с 15 добавлено и 9 удалено
  1. 15 0
      x509util/templates.go
  2. 0 9
      x509util/utils.go

+ 15 - 0
x509util/templates.go

@@ -14,6 +14,21 @@ const (
 // passed to the templates.
 type TemplateData map[string]interface{}
 
+// NewTemplateData creates a new map for templates data.
+func NewTemplateData() TemplateData {
+	return TemplateData{}
+}
+
+// CreateTemplateData creates a new TemplateData with the given common name and SANs.
+func CreateTemplateData(commonName string, sans []string) TemplateData {
+	return TemplateData{
+		SubjectKey: Subject{
+			CommonName: commonName,
+		},
+		SANsKey: CreateSANs(sans),
+	}
+}
+
 func (t TemplateData) Set(key string, v interface{}) {
 	t[key] = v
 }

+ 0 - 9
x509util/utils.go

@@ -38,15 +38,6 @@ func CreateSANs(sans []string) []SubjectAlternativeName {
 	return sanTypes
 }
 
-func CreateTemplateData(commonName string, sans []string) TemplateData {
-	return TemplateData{
-		SubjectKey: Subject{
-			CommonName: commonName,
-		},
-		SANsKey: CreateSANs(sans),
-	}
-}
-
 // generateSerialNumber returns a random serial number.
 func generateSerialNumber() (*big.Int, error) {
 	limit := new(big.Int).Lsh(big.NewInt(1), 128)