2019-03-11 18:56:48 +02:00
|
|
|
package certificate
|
2018-12-06 23:50:17 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2020-09-02 03:20:01 +02:00
|
|
|
"github.com/go-acme/lego/v4/acme"
|
|
|
|
"github.com/go-acme/lego/v4/log"
|
2018-12-06 23:50:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (c *Certifier) getAuthorizations(order acme.ExtendedOrder) ([]acme.Authorization, error) {
|
|
|
|
resc, errc := make(chan acme.Authorization), make(chan domainError)
|
|
|
|
|
2024-06-13 22:48:04 +02:00
|
|
|
delay := time.Second / time.Duration(c.overallRequestLimit)
|
2018-12-06 23:50:17 +02:00
|
|
|
|
|
|
|
for _, authzURL := range order.Authorizations {
|
|
|
|
time.Sleep(delay)
|
|
|
|
|
|
|
|
go func(authzURL string) {
|
|
|
|
authz, err := c.core.Authorizations.Get(authzURL)
|
|
|
|
if err != nil {
|
|
|
|
errc <- domainError{Domain: authz.Identifier.Value, Error: err}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resc <- authz
|
|
|
|
}(authzURL)
|
|
|
|
}
|
|
|
|
|
|
|
|
var responses []acme.Authorization
|
2023-08-19 18:05:33 +02:00
|
|
|
|
|
|
|
failures := newObtainError()
|
2024-03-20 21:30:35 +02:00
|
|
|
for range len(order.Authorizations) {
|
2018-12-06 23:50:17 +02:00
|
|
|
select {
|
|
|
|
case res := <-resc:
|
|
|
|
responses = append(responses, res)
|
|
|
|
case err := <-errc:
|
2023-08-19 18:05:33 +02:00
|
|
|
failures.Add(err.Domain, err.Error)
|
2018-12-06 23:50:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, auth := range order.Authorizations {
|
|
|
|
log.Infof("[%s] AuthURL: %s", order.Identifiers[i].Value, auth)
|
|
|
|
}
|
|
|
|
|
|
|
|
close(resc)
|
|
|
|
close(errc)
|
|
|
|
|
2023-08-19 18:05:33 +02:00
|
|
|
return responses, failures.Join()
|
2018-12-06 23:50:17 +02:00
|
|
|
}
|
|
|
|
|
2021-09-08 23:14:21 +02:00
|
|
|
func (c *Certifier) deactivateAuthorizations(order acme.ExtendedOrder, force bool) {
|
2019-10-25 00:28:26 +02:00
|
|
|
for _, authzURL := range order.Authorizations {
|
|
|
|
auth, err := c.core.Authorizations.Get(authzURL)
|
|
|
|
if err != nil {
|
|
|
|
log.Infof("Unable to get the authorization for: %s", authzURL)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2021-09-08 23:14:21 +02:00
|
|
|
if auth.Status == acme.StatusValid && !force {
|
2019-10-25 00:28:26 +02:00
|
|
|
log.Infof("Skipping deactivating of valid auth: %s", authzURL)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Infof("Deactivating auth: %s", authzURL)
|
|
|
|
if c.core.Authorizations.Deactivate(authzURL) != nil {
|
|
|
|
log.Infof("Unable to deactivate the authorization: %s", authzURL)
|
2018-12-06 23:50:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|