2019-03-11 16:56:48 +00:00
|
|
|
package certificate
|
2018-12-06 21:50:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2020-09-02 01:20:01 +00:00
|
|
|
"github.com/go-acme/lego/v4/acme"
|
|
|
|
"github.com/go-acme/lego/v4/log"
|
2018-12-06 21:50:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (c *Certifier) getAuthorizations(order acme.ExtendedOrder) ([]acme.Authorization, error) {
|
|
|
|
resc, errc := make(chan acme.Authorization), make(chan domainError)
|
|
|
|
|
2024-06-13 20:48:04 +00:00
|
|
|
delay := time.Second / time.Duration(c.overallRequestLimit)
|
2018-12-06 21:50:17 +00: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 16:05:33 +00:00
|
|
|
|
|
|
|
failures := newObtainError()
|
2024-03-20 19:30:35 +00:00
|
|
|
for range len(order.Authorizations) {
|
2018-12-06 21:50:17 +00:00
|
|
|
select {
|
|
|
|
case res := <-resc:
|
|
|
|
responses = append(responses, res)
|
|
|
|
case err := <-errc:
|
2023-08-19 16:05:33 +00:00
|
|
|
failures.Add(err.Domain, err.Error)
|
2018-12-06 21:50:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, auth := range order.Authorizations {
|
|
|
|
log.Infof("[%s] AuthURL: %s", order.Identifiers[i].Value, auth)
|
|
|
|
}
|
|
|
|
|
|
|
|
close(resc)
|
|
|
|
close(errc)
|
|
|
|
|
2023-08-19 16:05:33 +00:00
|
|
|
return responses, failures.Join()
|
2018-12-06 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 21:14:21 +00:00
|
|
|
func (c *Certifier) deactivateAuthorizations(order acme.ExtendedOrder, force bool) {
|
2019-10-24 22:28:26 +00: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 21:14:21 +00:00
|
|
|
if auth.Status == acme.StatusValid && !force {
|
2019-10-24 22:28:26 +00: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 21:50:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|