diff options
Diffstat (limited to 'rpkid/rpki')
-rw-r--r-- | rpkid/rpki/irdb/zookeeper.py | 11 | ||||
-rw-r--r-- | rpkid/rpki/rpkic.py | 7 |
2 files changed, 13 insertions, 5 deletions
diff --git a/rpkid/rpki/irdb/zookeeper.py b/rpkid/rpki/irdb/zookeeper.py index 6b72a8a8..86aabb08 100644 --- a/rpkid/rpki/irdb/zookeeper.py +++ b/rpkid/rpki/irdb/zookeeper.py @@ -457,7 +457,7 @@ class Zookeeper(object): @django.db.transaction.commit_on_success - def configure_child(self, filename, child_handle = None): + def configure_child(self, filename, child_handle = None, valid_until = None): """ Configure a new child of this RPKI entity, given the child's XML identity file as an input. Extracts the child's data from the @@ -472,7 +472,12 @@ class Zookeeper(object): if child_handle is None: child_handle = c.get("handle") - valid_until = rpki.sundial.now() + rpki.sundial.timedelta(days = 365) + if valid_until is None: + valid_until = rpki.sundial.now() + rpki.sundial.timedelta(days = 365) + else: + valid_until = rpki.sundial.datetime.fromXMLtime(valid_until) + if valid_until < rpki.sundial.now(): + raise PastExpiration, "Specified new expiration time %s has passed" % valid_until self.log("Child calls itself %r, we call it %r" % (c.get("handle"), child_handle)) @@ -791,7 +796,7 @@ class Zookeeper(object): if valid_until is None: valid_until = rpki.sundial.now() + rpki.sundial.timedelta(days = 365) else: - valid_until = rpki.sundial.fromXMLtime(valid_until) + valid_until = rpki.sundial.datetime.fromXMLtime(valid_until) if valid_until < rpki.sundial.now(): raise PastExpiration, "Specified new expiration time %s has passed" % valid_until diff --git a/rpkid/rpki/rpkic.py b/rpkid/rpki/rpkic.py index c5a9a919..8085db43 100644 --- a/rpkid/rpki/rpkic.py +++ b/rpkid/rpki/rpkic.py @@ -273,15 +273,18 @@ class main(Cmd): """ child_handle = None + valid_until = None - opts, argv = getopt.getopt(arg.split(), "", ["child_handle="]) + opts, argv = getopt.getopt(arg.split(), "", ["child_handle=", "valid_until="]) for o, a in opts: if o == "--child_handle": child_handle = a + elif o == "--valid_until": + valid_until = a if len(argv) != 1: raise BadCommandSyntax("Expecting filename of child's identity XML") - r, child_handle = self.zoo.configure_child(argv[0], child_handle) + r, child_handle = self.zoo.configure_child(argv[0], child_handle, valid_until) r.save("%s.%s.parent-response.xml" % (self.zoo.handle, child_handle), sys.stdout) self.zoo.synchronize_ca() |