forked from TrueCloudLab/lego
simple, without retriing
This commit is contained in:
parent
334ebd6ee6
commit
3ab9b75696
1 changed files with 4 additions and 18 deletions
22
acme/jws.go
22
acme/jws.go
|
@ -9,14 +9,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"errors"
|
|
||||||
"gopkg.in/square/go-jose.v1"
|
"gopkg.in/square/go-jose.v1"
|
||||||
"time"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TRY_COUNT = 10
|
|
||||||
const RETRY_PAUSE = time.Second
|
|
||||||
|
|
||||||
type jws struct {
|
type jws struct {
|
||||||
directoryURL string
|
directoryURL string
|
||||||
privKey crypto.PrivateKey
|
privKey crypto.PrivateKey
|
||||||
|
@ -101,24 +97,14 @@ func (j *jws) getNonce() error {
|
||||||
func (j *jws) Nonce() (string, error) {
|
func (j *jws) Nonce() (string, error) {
|
||||||
nonce := ""
|
nonce := ""
|
||||||
if len(j.nonces) == 0 {
|
if len(j.nonces) == 0 {
|
||||||
for i := 0; i < TRY_COUNT; i++ {
|
err := j.getNonce()
|
||||||
err := j.getNonce()
|
if err != nil {
|
||||||
if err != nil {
|
return nonce, err
|
||||||
return nonce, err
|
|
||||||
}
|
|
||||||
if len(j.nonces) != 0 {
|
|
||||||
// get nonce ok and can continue
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if i < TRY_COUNT-1 {
|
|
||||||
time.Sleep(RETRY_PAUSE)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(j.nonces) == 0 {
|
if len(j.nonces) == 0 {
|
||||||
return "", errors.New("Can't get nonce")
|
return "", errors.New("Can't get nonce")
|
||||||
}
|
}
|
||||||
|
|
||||||
nonce, j.nonces = j.nonces[len(j.nonces)-1], j.nonces[:len(j.nonces)-1]
|
nonce, j.nonces = j.nonces[len(j.nonces)-1], j.nonces[:len(j.nonces)-1]
|
||||||
return nonce, nil
|
return nonce, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue