Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
00bcbd36
Commit
00bcbd36
authored
Oct 28, 2016
by
neilpang
Browse files
fix performance, use cached nonce
parent
1befee5a
Changes
1
Show whitespace changes
Inline
Side-by-side
acme.sh
View file @
00bcbd36
...
@@ -1132,6 +1132,8 @@ _send_signed_request() {
...
@@ -1132,6 +1132,8 @@ _send_signed_request() {
payload64=$(printf "%s" "$payload" | _base64 | _urlencode)
payload64=$(printf "%s" "$payload" | _base64 | _urlencode)
_debug3 payload64 $payload64
_debug3 payload64 $payload64
if [ -z "$_CACHED_NONCE" ] ; then
_debug2 "Get nonce."
nonceurl="$API/directory"
nonceurl="$API/directory"
_headers="$(_get $nonceurl "onlyheader")"
_headers="$(_get $nonceurl "onlyheader")"
...
@@ -1142,8 +1144,11 @@ _send_signed_request() {
...
@@ -1142,8 +1144,11 @@ _send_signed_request() {
_debug3 _headers "$_headers"
_debug3 _headers "$_headers"
nonce="$( echo "$_headers" | grep "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
_CACHED_NONCE="$( echo "$_headers" | grep "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
else
_debug2 "Use _CACHED_NONCE" "$_CACHED_NONCE"
fi
nonce="$_CACHED_NONCE"
_debug3 nonce "$nonce"
_debug3 nonce "$nonce"
protected="$JWK_HEADERPLACE_PART1$nonce$JWK_HEADERPLACE_PART2"
protected="$JWK_HEADERPLACE_PART1$nonce$JWK_HEADERPLACE_PART2"
...
@@ -1160,6 +1165,7 @@ _send_signed_request() {
...
@@ -1160,6 +1165,7 @@ _send_signed_request() {
response="$(_post "$body" $url "$needbase64")"
response="$(_post "$body" $url "$needbase64")"
_CACHED_NONCE=""
if [ "$?" != "0" ] ; then
if [ "$?" != "0" ] ; then
_err "Can not post to $url"
_err "Can not post to $url"
return 1
return 1
...
@@ -1168,13 +1174,15 @@ _send_signed_request() {
...
@@ -1168,13 +1174,15 @@ _send_signed_request() {
response="$( echo "$response" | _normalizeJson )"
response="$( echo "$response" | _normalizeJson )"
responseHeaders="$(cat $HTTP_HEADER)"
responseHeaders="$(cat
"
$HTTP_HEADER
"
)"
_debug2 responseHeaders "$responseHeaders"
_debug2 responseHeaders "$responseHeaders"
_debug2 response "$response"
_debug2 response "$response"
code="$(grep "^HTTP" $HTTP_HEADER | _tail_n 1 | cut -d " " -f 2 | tr -d "\r\n" )"
code="$(grep "^HTTP" $HTTP_HEADER | _tail_n 1 | cut -d " " -f 2 | tr -d "\r\n" )"
_debug code $code
_debug code $code
_CACHED_NONCE="$(echo "$responseHeaders" | grep "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment