diff --git a/x509util/templates.go b/x509util/templates.go index 0467229e..f3e2bcd7 100644 --- a/x509util/templates.go +++ b/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 } diff --git a/x509util/utils.go b/x509util/utils.go index 6268107e..110d2644 100644 --- a/x509util/utils.go +++ b/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)