Move CreateTemplateData.

This commit is contained in:
Mariano Cano 2020-07-09 15:17:32 -07:00
parent 28ff122f83
commit 3c84453cf4
2 changed files with 15 additions and 9 deletions

View file

@ -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
}

View file

@ -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)