Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Adrien Dorsaz
acme-dns-tiny
Commits
48f6fa12
Commit
48f6fa12
authored
Aug 23, 2021
by
Adrien Dorsaz
Browse files
raise error if not any response found on _send_signed_request
ensure the nonce is used only once.
parent
2467b3b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
acme_dns_tiny.py
View file @
48f6fa12
...
@@ -65,6 +65,7 @@ def get_crt(config, log=LOGGER):
...
@@ -65,6 +65,7 @@ def get_crt(config, log=LOGGER):
payload64
=
_base64
(
json
.
dumps
(
payload
).
encode
(
"utf8"
))
payload64
=
_base64
(
json
.
dumps
(
payload
).
encode
(
"utf8"
))
protected
=
copy
.
deepcopy
(
private_acme_signature
)
protected
=
copy
.
deepcopy
(
private_acme_signature
)
protected
[
"nonce"
]
=
nonce
or
requests
.
get
(
acme_config
[
"newNonce"
]).
headers
[
'Replay-Nonce'
]
protected
[
"nonce"
]
=
nonce
or
requests
.
get
(
acme_config
[
"newNonce"
]).
headers
[
'Replay-Nonce'
]
del
nonce
protected
[
"url"
]
=
url
protected
[
"url"
]
=
url
if
url
==
acme_config
[
"newAccount"
]:
if
url
==
acme_config
[
"newAccount"
]:
if
"kid"
in
protected
:
if
"kid"
in
protected
:
...
@@ -84,12 +85,14 @@ def get_crt(config, log=LOGGER):
...
@@ -84,12 +85,14 @@ def get_crt(config, log=LOGGER):
response
=
requests
.
post
(
url
,
json
=
jose
,
headers
=
joseheaders
)
response
=
requests
.
post
(
url
,
json
=
jose
,
headers
=
joseheaders
)
except
requests
.
exceptions
.
RequestException
as
error
:
except
requests
.
exceptions
.
RequestException
as
error
:
response
=
error
.
response
response
=
error
.
response
finally
:
if
response
:
nonce
=
response
.
headers
[
'Replay-Nonce'
]
nonce
=
response
.
headers
[
'Replay-Nonce'
]
try
:
try
:
return
response
,
response
.
json
()
return
response
,
response
.
json
()
except
ValueError
:
# if body is empty or not JSON formatted
except
ValueError
:
# if body is empty or not JSON formatted
return
response
,
json
.
loads
(
"{}"
)
return
response
,
json
.
loads
(
"{}"
)
else
:
raise
RuntimeError
(
"Unable to get response from ACME server."
)
# main code
# main code
adtheaders
=
{
'User-Agent'
:
'acme-dns-tiny/2.2'
,
adtheaders
=
{
'User-Agent'
:
'acme-dns-tiny/2.2'
,
...
...
tools/acme_account_deactivate.py
View file @
48f6fa12
...
@@ -42,6 +42,7 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
...
@@ -42,6 +42,7 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
payload64
=
_b64
(
json
.
dumps
(
payload
).
encode
(
"utf8"
))
payload64
=
_b64
(
json
.
dumps
(
payload
).
encode
(
"utf8"
))
protected
=
copy
.
deepcopy
(
private_acme_signature
)
protected
=
copy
.
deepcopy
(
private_acme_signature
)
protected
[
"nonce"
]
=
nonce
or
requests
.
get
(
acme_config
[
"newNonce"
]).
headers
[
'Replay-Nonce'
]
protected
[
"nonce"
]
=
nonce
or
requests
.
get
(
acme_config
[
"newNonce"
]).
headers
[
'Replay-Nonce'
]
del
nonce
protected
[
"url"
]
=
url
protected
[
"url"
]
=
url
if
url
==
acme_config
[
"newAccount"
]:
if
url
==
acme_config
[
"newAccount"
]:
if
"kid"
in
protected
:
if
"kid"
in
protected
:
...
@@ -62,12 +63,14 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
...
@@ -62,12 +63,14 @@ def account_deactivate(accountkeypath, acme_directory, log=LOGGER):
response
=
requests
.
post
(
url
,
json
=
jose
,
headers
=
joseheaders
)
response
=
requests
.
post
(
url
,
json
=
jose
,
headers
=
joseheaders
)
except
requests
.
exceptions
.
RequestException
as
error
:
except
requests
.
exceptions
.
RequestException
as
error
:
response
=
error
.
response
response
=
error
.
response
finally
:
if
response
:
nonce
=
response
.
headers
[
'Replay-Nonce'
]
nonce
=
response
.
headers
[
'Replay-Nonce'
]
try
:
try
:
return
response
,
response
.
json
()
return
response
,
response
.
json
()
except
ValueError
:
# if body is empty or not JSON formatted
except
ValueError
:
# if body is empty or not JSON formatted
return
response
,
json
.
dumps
({})
return
response
,
json
.
loads
(
"{}"
)
else
:
raise
RuntimeError
(
"Unable to get response from ACME server."
)
# main code
# main code
adtheaders
=
{
'User-Agent'
:
'acme-dns-tiny/2.2'
}
adtheaders
=
{
'User-Agent'
:
'acme-dns-tiny/2.2'
}
...
...
tools/acme_account_rollover.py
View file @
48f6fa12
...
@@ -92,12 +92,14 @@ def account_rollover(old_accountkeypath, new_accountkeypath, acme_directory, log
...
@@ -92,12 +92,14 @@ def account_rollover(old_accountkeypath, new_accountkeypath, acme_directory, log
response
=
requests
.
post
(
url
,
json
=
jose
,
headers
=
joseheaders
)
response
=
requests
.
post
(
url
,
json
=
jose
,
headers
=
joseheaders
)
except
requests
.
exceptions
.
RequestException
as
error
:
except
requests
.
exceptions
.
RequestException
as
error
:
response
=
error
.
response
response
=
error
.
response
finally
:
if
response
:
nonce
=
response
.
headers
[
'Replay-Nonce'
]
nonce
=
response
.
headers
[
'Replay-Nonce'
]
try
:
try
:
return
response
,
response
.
json
()
return
response
,
response
.
json
()
except
ValueError
:
# if body is empty or not JSON formatted
except
ValueError
:
# if body is empty or not JSON formatted
return
response
,
json
.
dumps
({})
return
response
,
json
.
dumps
({})
else
:
raise
RuntimeError
(
"Unable to get response from ACME server."
)
# main code
# main code
adtheaders
=
{
'User-Agent'
:
'acme-dns-tiny/2.2'
}
adtheaders
=
{
'User-Agent'
:
'acme-dns-tiny/2.2'
}
...
...
Write
Preview
Supports
Markdown
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