mirror of
https://github.com/go-acme/lego.git
synced 2024-12-26 03:09:37 +02:00
Certificates are PEM encoded by default now
This commit is contained in:
parent
caa6e78289
commit
dcdcde03aa
@ -151,7 +151,7 @@ func (c *Client) AgreeToTos() error {
|
|||||||
|
|
||||||
// ObtainCertificates tries to obtain certificates from the CA server
|
// ObtainCertificates tries to obtain certificates from the CA server
|
||||||
// using the challenges it has configured. The returned certificates are
|
// using the challenges it has configured. The returned certificates are
|
||||||
// DER encoded byte slices.
|
// PEM encoded byte slices.
|
||||||
func (c *Client) ObtainCertificates(domains []string) ([]CertificateResource, error) {
|
func (c *Client) ObtainCertificates(domains []string) ([]CertificateResource, error) {
|
||||||
logger().Print("Obtaining certificates...")
|
logger().Print("Obtaining certificates...")
|
||||||
challenges := c.getChallenges(domains)
|
challenges := c.getChallenges(domains)
|
||||||
@ -165,7 +165,7 @@ func (c *Client) ObtainCertificates(domains []string) ([]CertificateResource, er
|
|||||||
return c.requestCertificates(challenges)
|
return c.requestCertificates(challenges)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RevokeCertificate takes a DER encoded certificate and tries to revoke it at the CA.
|
// RevokeCertificate takes a PEM encoded certificate and tries to revoke it at the CA.
|
||||||
func (c *Client) RevokeCertificate(certificate []byte) error {
|
func (c *Client) RevokeCertificate(certificate []byte) error {
|
||||||
encodedCert := base64.URLEncoding.EncodeToString(certificate)
|
encodedCert := base64.URLEncoding.EncodeToString(certificate)
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ func (c *Client) requestCertificate(authz *authorizationResource, result chan Ce
|
|||||||
// Otherwise the body is the certificate.
|
// Otherwise the body is the certificate.
|
||||||
if len(cert) > 0 {
|
if len(cert) > 0 {
|
||||||
cerRes.CertStableURL = resp.Header.Get("Content-Location")
|
cerRes.CertStableURL = resp.Header.Get("Content-Location")
|
||||||
cerRes.Certificate = cert
|
cerRes.Certificate = pemEncode(cert)
|
||||||
result <- cerRes
|
result <- cerRes
|
||||||
} else {
|
} else {
|
||||||
// The certificate was granted but is not yet issued.
|
// The certificate was granted but is not yet issued.
|
||||||
|
@ -29,6 +29,9 @@ func pemEncode(data interface{}) []byte {
|
|||||||
switch key := data.(type) {
|
switch key := data.(type) {
|
||||||
case *rsa.PrivateKey:
|
case *rsa.PrivateKey:
|
||||||
pemBlock = &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}
|
pemBlock = &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}
|
||||||
|
break
|
||||||
|
case []byte:
|
||||||
|
pemBlock = &pem.Block{Type: "CERTIFICATE", Bytes: data.([]byte)}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pem.EncodeToMemory(pemBlock)
|
return pem.EncodeToMemory(pemBlock)
|
||||||
|
Loading…
Reference in New Issue
Block a user