mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-19 16:20:52 +00:00
timedelta, not seconds
This commit is contained in:
parent
1e1aad8cc8
commit
a98d784ce4
@ -1,5 +1,6 @@
|
||||
from datetime import (
|
||||
datetime,
|
||||
timedelta,
|
||||
)
|
||||
import json
|
||||
|
||||
@ -120,6 +121,7 @@ def add(ctx, name, public_key):
|
||||
save_grid_manager(
|
||||
_config_path_from_option(ctx.parent.params["config"]),
|
||||
ctx.obj.grid_manager,
|
||||
create=False,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
@ -185,14 +185,25 @@ class _GridManager(object):
|
||||
def public_identity(self):
|
||||
return ed25519.string_from_verifying_key(self._public_key)
|
||||
|
||||
def sign(self, name, expiry_seconds):
|
||||
def sign(self, name, expiry):
|
||||
"""
|
||||
Create a new signed certificate for a particular server
|
||||
|
||||
:param str name: the server to create a certificate for
|
||||
|
||||
:param timedelta expiry: how far in the future the certificate
|
||||
should expire.
|
||||
|
||||
:returns: a dict defining the certificate (it has
|
||||
"certificate" and "signature" keys).
|
||||
"""
|
||||
try:
|
||||
srv = self._storage_servers[name]
|
||||
except KeyError:
|
||||
raise KeyError(
|
||||
"No storage server named '{}'".format(name)
|
||||
)
|
||||
expiration = datetime.utcnow() + timedelta(seconds=expiry_seconds)
|
||||
expiration = datetime.utcnow() + expiry
|
||||
epoch_offset = (expiration - datetime(1970, 1, 1)).total_seconds()
|
||||
cert_info = {
|
||||
"expires": epoch_offset,
|
||||
|
Loading…
x
Reference in New Issue
Block a user