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"
|
||||
"net/http"
|
||||
|
||||
"errors"
|
||||
"gopkg.in/square/go-jose.v1"
|
||||
"time"
|
||||
"errors"
|
||||
)
|
||||
|
||||
const TRY_COUNT = 10
|
||||
const RETRY_PAUSE = time.Second
|
||||
|
||||
type jws struct {
|
||||
directoryURL string
|
||||
privKey crypto.PrivateKey
|
||||
|
@ -101,24 +97,14 @@ func (j *jws) getNonce() error {
|
|||
func (j *jws) Nonce() (string, error) {
|
||||
nonce := ""
|
||||
if len(j.nonces) == 0 {
|
||||
for i := 0; i < TRY_COUNT; i++ {
|
||||
err := j.getNonce()
|
||||
if err != nil {
|
||||
return nonce, err
|
||||
}
|
||||
if len(j.nonces) != 0 {
|
||||
// get nonce ok and can continue
|
||||
break
|
||||
}
|
||||
if i < TRY_COUNT-1 {
|
||||
time.Sleep(RETRY_PAUSE)
|
||||
}
|
||||
err := j.getNonce()
|
||||
if err != nil {
|
||||
return nonce, err
|
||||
}
|
||||
}
|
||||
if len(j.nonces) == 0 {
|
||||
return "", errors.New("Can't get nonce")
|
||||
}
|
||||
|
||||
nonce, j.nonces = j.nonces[len(j.nonces)-1], j.nonces[:len(j.nonces)-1]
|
||||
return nonce, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue