forked from TrueCloudLab/lego
Wrap []byte for DER certificates in its own type.
This commit is contained in:
parent
141900789d
commit
7f6f790253
2 changed files with 4 additions and 2 deletions
|
@ -357,7 +357,7 @@ func (c *Client) requestCertificate(authz *authorizationResource, result chan Ce
|
|||
// Otherwise the body is the certificate.
|
||||
if len(cert) > 0 {
|
||||
cerRes.CertStableURL = resp.Header.Get("Content-Location")
|
||||
cerRes.Certificate = pemEncode(cert)
|
||||
cerRes.Certificate = pemEncode(derCertificateBytes(cert))
|
||||
result <- cerRes
|
||||
} else {
|
||||
// The certificate was granted but is not yet issued.
|
||||
|
|
|
@ -10,6 +10,8 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type derCertificateBytes []byte
|
||||
|
||||
func generatePrivateKey(keyLength int) (*rsa.PrivateKey, error) {
|
||||
return rsa.GenerateKey(rand.Reader, keyLength)
|
||||
}
|
||||
|
@ -30,7 +32,7 @@ func pemEncode(data interface{}) []byte {
|
|||
case *rsa.PrivateKey:
|
||||
pemBlock = &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}
|
||||
break
|
||||
case []byte:
|
||||
case derCertificateBytes:
|
||||
pemBlock = &pem.Block{Type: "CERTIFICATE", Bytes: data.([]byte)}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue