fix: update lego.

This commit is contained in:
Ludovic Fernandez 2018-04-09 18:28:03 +02:00 committed by Traefiker Bot
parent 2d0d320d05
commit b1be062437
48 changed files with 2979 additions and 1076 deletions

View file

@ -482,6 +482,7 @@ func (c *Client) createOrderForIdentifiers(domains []string) (orderResource, err
orderRes := orderResource{
URL: hdr.Get("Location"),
Domains: domains,
orderMessage: response,
}
return orderRes, nil
@ -590,7 +591,7 @@ func (c *Client) requestCertificateForOrder(order orderResource, bundle bool, pr
}
// determine certificate name(s) based on the authorization resources
commonName := order.Identifiers[0].Value
commonName := order.Domains[0]
var san []string
for _, auth := range order.Identifiers {
san = append(san, auth.Value)
@ -606,12 +607,7 @@ func (c *Client) requestCertificateForOrder(order orderResource, bundle bool, pr
}
func (c *Client) requestCertificateForCsr(order orderResource, bundle bool, csr []byte, privateKeyPem []byte) (CertificateResource, error) {
commonName := order.Identifiers[0].Value
var authURLs []string
for _, auth := range order.Identifiers[1:] {
authURLs = append(authURLs, auth.Value)
}
commonName := order.Domains[0]
csrString := base64.RawURLEncoding.EncodeToString(csr)
var retOrder orderMessage

View file

@ -34,7 +34,8 @@ type accountMessage struct {
}
type orderResource struct {
URL string `json:"url,omitempty"`
URL string `json:"url,omitempty"`
Domains []string `json:"domains,omitempty"`
orderMessage `json:"body,omitempty"`
}

View file

@ -4,14 +4,13 @@
package azure
import (
"context"
"fmt"
"os"
"strings"
"time"
"github.com/Azure/azure-sdk-for-go/arm/dns"
"strings"
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2017-09-01/dns"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
@ -26,6 +25,8 @@ type DNSProvider struct {
subscriptionId string
tenantId string
resourceGroup string
context context.Context
}
// NewDNSProvider returns a DNSProvider instance configured for azure.
@ -53,6 +54,8 @@ func NewDNSProviderCredentials(clientId, clientSecret, subscriptionId, tenantId,
subscriptionId: subscriptionId,
tenantId: tenantId,
resourceGroup: resourceGroup,
// TODO: A timeout can be added here for cancellation purposes.
context: context.Background(),
}, nil
}
@ -82,7 +85,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error {
TxtRecords: &[]dns.TxtRecord{dns.TxtRecord{Value: &[]string{value}}},
},
}
_, err = rsc.CreateOrUpdate(c.resourceGroup, zone, relative, dns.TXT, rec, "", "")
_, err = rsc.CreateOrUpdate(c.context, c.resourceGroup, zone, relative, dns.TXT, rec, "", "")
if err != nil {
return err
@ -109,7 +112,7 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error {
rsc := dns.NewRecordSetsClient(c.subscriptionId)
spt, err := c.newServicePrincipalTokenFromCredentials(azure.PublicCloud.ResourceManagerEndpoint)
rsc.Authorizer = autorest.NewBearerAuthorizer(spt)
_, err = rsc.Delete(c.resourceGroup, zone, relative, dns.TXT, "")
_, err = rsc.Delete(c.context, c.resourceGroup, zone, relative, dns.TXT, "")
if err != nil {
return err
}
@ -130,7 +133,7 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (string, error) {
dc := dns.NewZonesClient(c.subscriptionId)
dc.Authorizer = autorest.NewBearerAuthorizer(spt)
zone, err := dc.Get(c.resourceGroup, acmev2.UnFqdn(authZone))
zone, err := dc.Get(c.context, c.resourceGroup, acmev2.UnFqdn(authZone))
if err != nil {
return "", err

View file

@ -72,7 +72,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
authZone = acmev2.UnFqdn(authZone)
reqURL := fmt.Sprintf("%s/v2/domains/%s/records", digitalOceanBaseURL, authZone)
reqData := txtRecordRequest{RecordType: "TXT", Name: fqdn, Data: value, TTL: 60}
reqData := txtRecordRequest{RecordType: "TXT", Name: fqdn, Data: value, TTL: 30}
body, err := json.Marshal(reqData)
if err != nil {
return err
@ -169,5 +169,5 @@ var digitalOceanBaseURL = "https://api.digitalocean.com"
// Timeout returns the timeout and interval to use when checking for DNS
// propagation. Adjusting here to cope with spikes in propagation times.
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
return 90 * time.Second, 5 * time.Second
return 60 * time.Second, 5 * time.Second
}