lego provides PEM-encoded certificate bytes for us

This commit is contained in:
Matthew Holt 2015-10-17 21:18:46 -06:00
parent 7568b0e215
commit 9f9de389d5
2 changed files with 1 additions and 14 deletions

View File

@ -8,19 +8,6 @@ import (
"os" "os"
) )
// saveCertificate saves a DER-encoded (binary format) certificate
// to file.
func saveCertificate(certBytes []byte, file string) error {
pemCert := pem.Block{Type: "CERTIFICATE", Bytes: certBytes}
certOut, err := os.Create(file)
if err != nil {
return err
}
pem.Encode(certOut, &pemCert)
certOut.Close()
return nil
}
// loadRSAPrivateKey loads a PEM-encoded RSA private key from file. // loadRSAPrivateKey loads a PEM-encoded RSA private key from file.
func loadRSAPrivateKey(file string) (*rsa.PrivateKey, error) { func loadRSAPrivateKey(file string) (*rsa.PrivateKey, error) {
keyBytes, err := ioutil.ReadFile(file) keyBytes, err := ioutil.ReadFile(file)

View File

@ -144,7 +144,7 @@ func saveCertsAndKeys(certificates []acme.CertificateResource) error {
os.MkdirAll(storage.Site(cert.Domain), 0700) os.MkdirAll(storage.Site(cert.Domain), 0700)
// Save cert // Save cert
err := saveCertificate(cert.Certificate, storage.SiteCertFile(cert.Domain)) err := ioutil.WriteFile(storage.SiteCertFile(cert.Domain), cert.Certificate, 0600)
if err != nil { if err != nil {
return err return err
} }