From 054c88f817983d7b5daacf78bb2fe8c9505b72f1 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 6 Mar 2016 03:10:23 +0100 Subject: Refactor Bundle and NewDesire --- certificate.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'certificate.go') diff --git a/certificate.go b/certificate.go index 318f8bb..3f985bd 100644 --- a/certificate.go +++ b/certificate.go @@ -1,25 +1,28 @@ package acme +import "crypto/tls" + type CSR struct { Resource Resource `json:"resource"` // new-cert CSR string `json:"csr"` } -func (p *Provider) Bundle(s Signer, d *Desire) error { - csr, err := NewCSR(d.Cert, d.altnames) +func (p *Provider) Bundle(s Signer, d *Desire) (tls.Certificate, error) { + cert := tls.Certificate{PrivateKey: d.key} + csr, err := NewCSR(d.key, d.altnames) if err != nil { - return err + return cert, err } crt, up, err := p.RequestCert(s, d, csr) if err != nil { - return err + return cert, err } ca, err := p.GetCert(up) if err != nil { - return err + return cert, err } - d.Cert.Certificate = [][]byte{crt, ca} - return nil + cert.Certificate = [][]byte{crt, ca} + return cert, nil } func (p *Provider) RequestCert(s Signer, d *Desire, csr string) ([]byte, string, error) { -- cgit v1.2.3