Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
1befee5a
Commit
1befee5a
authored
Oct 28, 2016
by
neilpang
Browse files
fix performance
parent
5982f4bc
Changes
1
Show whitespace changes
Inline
Side-by-side
acme.sh
View file @
1befee5a
...
@@ -833,6 +833,13 @@ _calcjwk() {
...
@@ -833,6 +833,13 @@ _calcjwk() {
_usage
"Usage: _calcjwk keyfile"
_usage
"Usage: _calcjwk keyfile"
return
1
return
1
fi
fi
if
[
"
$JWK_HEADER
"
]
&&
[
"
$__CACHED_JWK_KEY_FILE
"
=
"
$keyfile
"
]
;
then
_debug2
"Use cached jwk for file:
$__CACHED_JWK_KEY_FILE
"
return
0
fi
EC_SIGN
=
""
EC_SIGN
=
""
if
grep
"BEGIN RSA PRIVATE KEY"
"
$keyfile
"
>
/dev/null 2>&1
;
then
if
grep
"BEGIN RSA PRIVATE KEY"
"
$keyfile
"
>
/dev/null 2>&1
;
then
_debug
"RSA key"
_debug
"RSA key"
...
@@ -901,6 +908,7 @@ _calcjwk() {
...
@@ -901,6 +908,7 @@ _calcjwk() {
fi
fi
_debug3 JWK_HEADER
"
$JWK_HEADER
"
_debug3 JWK_HEADER
"
$JWK_HEADER
"
__CACHED_JWK_KEY_FILE
=
"
$keyfile
"
}
}
_time
()
{
_time
()
{
...
@@ -930,35 +938,44 @@ _inithttp() {
...
@@ -930,35 +938,44 @@ _inithttp() {
_debug2 HTTP_HEADER
"
$HTTP_HEADER
"
_debug2 HTTP_HEADER
"
$HTTP_HEADER
"
fi
fi
if
[
-z
"
$CURL
"
]
;
then
if
[
"
$__HTTP_INITIALIZED
"
]
;
then
CURL
=
"curl -L --silent --dump-header
$HTTP_HEADER
"
if
[
"
$_ACME_CURL$_ACME_WGET
"
]
;
then
_debug2
"Http already initialized."
return
0
fi
fi
if
[
-z
"
$_ACME_CURL
"
]
&&
_exists
"curl"
;
then
_ACME_CURL
=
"curl -L --silent --dump-header
$HTTP_HEADER
"
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"2"
]
;
then
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"2"
]
;
then
_CURL_DUMP
=
"
$(
_mktemp
)
"
_CURL_DUMP
=
"
$(
_mktemp
)
"
CURL
=
"
$CURL
--trace-ascii
$_CURL_DUMP
"
_ACME_
CURL
=
"
$
_ACME_
CURL
--trace-ascii
$_CURL_DUMP
"
fi
fi
if
[
"
$CA_BUNDLE
"
]
;
then
if
[
"
$CA_BUNDLE
"
]
;
then
CURL
=
"
$CURL
--cacert
$CA_BUNDLE
"
_ACME_
CURL
=
"
$
_ACME_
CURL
--cacert
$CA_BUNDLE
"
fi
fi
if
[
"
$HTTPS_INSECURE
"
]
;
then
if
[
"
$HTTPS_INSECURE
"
]
;
then
CURL
=
"
$CURL
--insecure "
_ACME_
CURL
=
"
$
_ACME_
CURL
--insecure "
fi
fi
fi
fi
if
[
-z
"
$WGET
"
]
;
then
if
[
-z
"
$
_ACME_
WGET
"
]
&&
_exists
"wget"
;
then
WGET
=
"wget -q"
_ACME_
WGET
=
"wget -q"
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"2"
]
;
then
if
[
"
$DEBUG
"
]
&&
[
"
$DEBUG
"
-ge
"2"
]
;
then
WGET
=
"
$WGET
-d "
_ACME_
WGET
=
"
$
_ACME_
WGET
-d "
fi
fi
if
[
"
$CA_BUNDLE
"
]
;
then
if
[
"
$CA_BUNDLE
"
]
;
then
WGET
=
"
$WGET
--ca-certificate
$CA_BUNDLE
"
_ACME_
WGET
=
"
$
_ACME_
WGET
--ca-certificate
$CA_BUNDLE
"
fi
fi
if
[
"
$HTTPS_INSECURE
"
]
;
then
if
[
"
$HTTPS_INSECURE
"
]
;
then
WGET
=
"
$WGET
--no-check-certificate "
_ACME_
WGET
=
"
$
_ACME_
WGET
--no-check-certificate "
fi
fi
fi
fi
__HTTP_INITIALIZED
=
1
}
}
...
@@ -978,8 +995,8 @@ _post() {
...
@@ -978,8 +995,8 @@ _post() {
_inithttp
_inithttp
if
_exists
"curl"
;
then
if
[
"
$_ACME_CURL
"
]
;
then
_CURL
=
"
$CURL
"
_CURL
=
"
$
_ACME_
CURL
"
_debug
"_CURL"
"
$_CURL
"
_debug
"_CURL"
"
$_CURL
"
if
[
"
$needbase64
"
]
;
then
if
[
"
$needbase64
"
]
;
then
response
=
"
$(
$_CURL
--user-agent
"
$USER_AGENT
"
-X
$httpmethod
-H
"
$_H1
"
-H
"
$_H2
"
-H
"
$_H3
"
-H
"
$_H4
"
-H
"
$_H5
"
--data
"
$body
"
"
$url
"
| _base64
)
"
response
=
"
$(
$_CURL
--user-agent
"
$USER_AGENT
"
-X
$httpmethod
-H
"
$_H1
"
-H
"
$_H2
"
-H
"
$_H3
"
-H
"
$_H4
"
-H
"
$_H5
"
--data
"
$body
"
"
$url
"
| _base64
)
"
...
@@ -994,19 +1011,19 @@ _post() {
...
@@ -994,19 +1011,19 @@ _post() {
_err
"
$(
cat
"
$_CURL_DUMP
"
)
"
_err
"
$(
cat
"
$_CURL_DUMP
"
)
"
fi
fi
fi
fi
elif
_exists
"wget"
;
then
elif
[
"
$_ACME_WGET
"
]
;
then
_debug
"WGET"
"
$WGET
"
_debug
"
_ACME_
WGET"
"
$
_ACME_
WGET
"
if
[
"
$needbase64
"
]
;
then
if
[
"
$needbase64
"
]
;
then
if
[
"
$httpmethod
"
=
"POST"
]
;
then
if
[
"
$httpmethod
"
=
"POST"
]
;
then
response
=
"
$(
$WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--post-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
| _base64
)
"
response
=
"
$(
$
_ACME_
WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--post-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
| _base64
)
"
else
else
response
=
"
$(
$WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--method
$httpmethod
--body-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
| _base64
)
"
response
=
"
$(
$
_ACME_
WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--method
$httpmethod
--body-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
| _base64
)
"
fi
fi
else
else
if
[
"
$httpmethod
"
=
"POST"
]
;
then
if
[
"
$httpmethod
"
=
"POST"
]
;
then
response
=
"
$(
$WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--post-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
)
"
response
=
"
$(
$
_ACME_
WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--post-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
)
"
else
else
response
=
"
$(
$WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--method
$httpmethod
--body-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
)
"
response
=
"
$(
$
_ACME_
WGET
-S
-O
-
--user-agent
=
"
$USER_AGENT
"
--header
"
$_H5
"
--header
"
$_H4
"
--header
"
$_H3
"
--header
"
$_H2
"
--header
"
$_H1
"
--method
$httpmethod
--body-data
=
"
$body
"
"
$url
"
2>
"
$HTTP_HEADER
"
)
"
fi
fi
fi
fi
_ret
=
"
$?
"
_ret
=
"
$?
"
...
@@ -1039,8 +1056,8 @@ _get() {
...
@@ -1039,8 +1056,8 @@ _get() {
_inithttp
_inithttp
if
_exists
"curl"
;
then
if
[
"
$_ACME_CURL
"
]
;
then
_CURL
=
"
$CURL
"
_CURL
=
"
$
_ACME_
CURL
"
if
[
"
$t
"
]
;
then
if
[
"
$t
"
]
;
then
_CURL
=
"
$_CURL
--connect-timeout
$t
"
_CURL
=
"
$_CURL
--connect-timeout
$t
"
fi
fi
...
@@ -1058,8 +1075,8 @@ _get() {
...
@@ -1058,8 +1075,8 @@ _get() {
_err
"
$(
cat
"
$_CURL_DUMP
"
)
"
_err
"
$(
cat
"
$_CURL_DUMP
"
)
"
fi
fi
fi
fi
elif
_exists
"wget"
;
then
elif
[
"
$_ACME_WGET
"
]
;
then
_WGET
=
"
$WGET
"
_WGET
=
"
$
_ACME_
WGET
"
if
[
"
$t
"
]
;
then
if
[
"
$t
"
]
;
then
_WGET
=
"
$_WGET
--timeout=
$t
"
_WGET
=
"
$_WGET
--timeout=
$t
"
fi
fi
...
@@ -3194,6 +3211,7 @@ revoke() {
...
@@ -3194,6 +3211,7 @@ revoke() {
data
=
"{
\"
resource
\"
:
\"
revoke-cert
\"
,
\"
certificate
\"
:
\"
$cert
\"
}"
data
=
"{
\"
resource
\"
:
\"
revoke-cert
\"
,
\"
certificate
\"
:
\"
$cert
\"
}"
uri
=
"
$API
/acme/revoke-cert"
uri
=
"
$API
/acme/revoke-cert"
if
[
-f
"
$CERT_KEY_PATH
"
]
;
then
_info
"Try domain key first."
_info
"Try domain key first."
if
_send_signed_request
$uri
"
$data
"
""
"
$CERT_KEY_PATH
"
;
then
if
_send_signed_request
$uri
"
$data
"
""
"
$CERT_KEY_PATH
"
;
then
if
[
-z
"
$response
"
]
;
then
if
[
-z
"
$response
"
]
;
then
...
@@ -3205,8 +3223,11 @@ revoke() {
...
@@ -3205,8 +3223,11 @@ revoke() {
_err
"
$response
"
_err
"
$response
"
fi
fi
fi
fi
else
_info
"Domain key file doesn't exists."
fi
_info
"T
hen t
ry account key."
_info
"Try account key."
if
_send_signed_request
$uri
"
$data
"
""
"
$ACCOUNT_KEY_PATH
"
;
then
if
_send_signed_request
$uri
"
$data
"
""
"
$ACCOUNT_KEY_PATH
"
;
then
if
[
-z
"
$response
"
]
;
then
if
[
-z
"
$response
"
]
;
then
...
...
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