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
1530abbd
Unverified
Commit
1530abbd
authored
Mar 26, 2021
by
Jan-Philipp Benecke
Browse files
Make uploading cert to subaccount possible
parent
a694b469
Changes
1
Hide whitespace changes
Inline
Side-by-side
deploy/cleverreach.sh
View file @
1530abbd
...
...
@@ -25,6 +25,7 @@ cleverreach_deploy() {
_getdeployconf DEPLOY_CLEVERREACH_CLIENT_ID
_getdeployconf DEPLOY_CLEVERREACH_CLIENT_SECRET
_getdeployconf DEPLOY_CLEVERREACH_SUBCLIENT_ID
if
[
-z
"
${
DEPLOY_CLEVERREACH_CLIENT_ID
}
"
]
;
then
_err
"CleverReach Client ID is not found, please define DEPLOY_CLEVERREACH_CLIENT_ID."
...
...
@@ -37,6 +38,7 @@ cleverreach_deploy() {
_savedeployconf DEPLOY_CLEVERREACH_CLIENT_ID
"
${
DEPLOY_CLEVERREACH_CLIENT_ID
}
"
_savedeployconf DEPLOY_CLEVERREACH_CLIENT_SECRET
"
${
DEPLOY_CLEVERREACH_CLIENT_SECRET
}
"
_savedeployconf DEPLOY_CLEVERREACH_SUBCLIENT_ID
"
${
DEPLOY_CLEVERREACH_SUBCLIENT_ID
}
"
_info
"Obtaining a CleverReach access token"
...
...
@@ -50,14 +52,26 @@ cleverreach_deploy() {
_debug _regex
"
$_regex
"
_access_token
=
$(
echo
"
$_auth_result
"
| _json_decode |
sed
-n
"s/
$_regex
/
\1
/p"
)
if
${
DEPLOY_CLEVERREACH_SUBCLIENT_ID
}
;
then
_info
"Obtaining token for sub-client"
export
_H1
=
"Authorization: Bearer
${
_access_token
}
"
_subclient_token_result
=
"
$(
_get
"https://rest.cleverreach.com/v3/clients/
$DEPLOY_CLEVERREACH_SUBCLIENT_ID
}/token"
)
"
_access_token
=
$(
echo
"
$_subclient_token_result
"
| _json_decode |
sed
-n
"s/
$_regex
/
\1
/p"
)
_debug
"Destroying parent token at CleverReach"
_post
""
"https://rest.cleverreach.com/v3/oauth/token.json"
""
"DELETE"
"application/json"
fi
_info
"Uploading certificate and key to CleverReach"
_certData
=
"{
\"
cert
\"
:
\"
$(
_json_encode <
"
$_cfullchain
"
)
\"
,
\"
key
\"
:
\"
$(
_json_encode <
"
$_ckey
"
)
\"
}"
export
_H1
=
"Authorization: Bearer
${
_access_token
}
"
_add_cert_result
=
"
$(
_post
"
$_certData
"
"https://rest.cleverreach.com/v3/ssl"
""
"POST"
"application/json"
)
"
_debug
"Destroying token at CleverReach"
_post
""
"https://rest.cleverreach.com/v3/oauth/token.json"
""
"DELETE"
"application/json"
if
!
${
DEPLOY_CLEVERREACH_SUBCLIENT_ID
}
;
then
_debug
"Destroying token at CleverReach"
_post
""
"https://rest.cleverreach.com/v3/oauth/token.json"
""
"DELETE"
"application/json"
fi
if
!
echo
"
$_add_cert_result
"
|
grep
'"error":'
>
/dev/null
;
then
_info
"Uploaded certificate successfully"
...
...
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