From 38677aaa58eb76a416fa42146956f3e3a5981e75 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 24 Jun 2019 12:16:10 -0600 Subject: caddytls: Support tags for manually-loaded certificates --- modules/caddytls/fileloader.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'modules/caddytls/fileloader.go') diff --git a/modules/caddytls/fileloader.go b/modules/caddytls/fileloader.go index 63592f9..d8e2d21 100644 --- a/modules/caddytls/fileloader.go +++ b/modules/caddytls/fileloader.go @@ -21,14 +21,15 @@ type fileLoader []CertKeyFilePair // CertKeyFilePair pairs certificate and key file names along with their // encoding format so that they can be loaded from disk. type CertKeyFilePair struct { - Certificate string `json:"certificate"` - Key string `json:"key"` - Format string `json:"format,omitempty"` // "pem" is default + Certificate string `json:"certificate"` + Key string `json:"key"` + Format string `json:"format,omitempty"` // "pem" is default + Tags []string `json:"tags,omitempty"` } // LoadCertificates returns the certificates to be loaded by fl. -func (fl fileLoader) LoadCertificates() ([]tls.Certificate, error) { - var certs []tls.Certificate +func (fl fileLoader) LoadCertificates() ([]Certificate, error) { + var certs []Certificate for _, pair := range fl { certData, err := ioutil.ReadFile(pair.Certificate) if err != nil { @@ -52,7 +53,7 @@ func (fl fileLoader) LoadCertificates() ([]tls.Certificate, error) { return nil, err } - certs = append(certs, cert) + certs = append(certs, Certificate{Certificate: cert, Tags: pair.Tags}) } return certs, nil } -- cgit v1.2.3