1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
|
"""
This is a command line configuration and control tool for rpkid et al.
Type "help" on the prompt, or run the program with the --help option for an
overview of the available commands; type "help foo" for (more) detailed help
on the "foo" command.
This program is a rewrite of the old myrpki program, replacing ten
zillion XML and X.509 disk files and subprocess calls to the OpenSSL
command line tool with SQL data and direct calls to the rpki.POW
library. This version abandons all pretense that this program might
somehow work without rpki.POW, lxml, and Django installed, but since
those packages are required for rpkid anyway, this seems like a small
price to pay for major simplification of the code and better
integration with the Django-based GUI interface.
$Id$
Copyright (C) 2009--2013 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
# NB: As of this writing, I'm trying really hard to avoid having this
# program depend on a Django settings.py file. This may prove to be a
# waste of time in the long run, but for for now, this means that one
# has to be careful about exactly how and when one imports Django
# modules, or anything that imports Django modules. Bottom line is
# that we don't import such modules until we need them.
import os
import getopt
import sys
import time
import rpki.config
import rpki.sundial
import rpki.log
import rpki.oids
import rpki.http
import rpki.resource_set
import rpki.relaxng
import rpki.exceptions
import rpki.left_right
import rpki.x509
import rpki.async
import rpki.version
from rpki.cli import Cmd, BadCommandSyntax
class BadPrefixSyntax(Exception): "Bad prefix syntax."
class CouldntTalkToDaemon(Exception): "Couldn't talk to daemon."
class BadXMLMessage(Exception): "Bad XML message."
class PastExpiration(Exception): "Expiration date has already passed."
class CantRunRootd(Exception): "Can't run rootd."
class main(Cmd):
prompt = "rpkic> "
completedefault = Cmd.filename_complete
def __init__(self):
os.environ["TZ"] = "UTC"
time.tzset()
self.cfg_file = None
self.handle = None
profile = None
opts, self.argv = getopt.getopt(sys.argv[1:], "c:hi:?",
["config=", "help", "identity=", "profile="])
for o, a in opts:
if o in ("-c", "--config"):
self.cfg_file = a
elif o in ("-h", "--help", "-?"):
self.argv = ["help"]
elif o in ("-i", "--identity"):
self.handle = a
elif o == "--profile":
profile = a
if self.argv and self.argv[0] == "help":
Cmd.__init__(self, self.argv)
elif profile:
import cProfile
prof = cProfile.Profile()
try:
prof.runcall(self.main)
finally:
prof.dump_stats(profile)
print "Dumped profile data to %s" % profile
else:
self.main()
def main(self):
rpki.log.init("rpkic", use_syslog = False)
self.read_config()
Cmd.__init__(self, self.argv)
if self.argv:
sys.exit(1 if self.last_command_failed else 0)
def read_config(self):
global rpki # pylint: disable=W0602
cfg = rpki.config.parser(self.cfg_file, "myrpki")
cfg.set_global_flags()
self.histfile = cfg.get("history_file", os.path.expanduser("~/.rpkic_history"))
self.autosync = cfg.getboolean("autosync", True, section = "rpkic")
from django.conf import settings
settings.configure(
DATABASES = { "default" : {
"ENGINE" : "django.db.backends.mysql",
"NAME" : cfg.get("sql-database", section = "irdbd"),
"USER" : cfg.get("sql-username", section = "irdbd"),
"PASSWORD" : cfg.get("sql-password", section = "irdbd"),
"HOST" : "",
"PORT" : "",
"OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}},
INSTALLED_APPS = ("rpki.irdb",),
)
import rpki.irdb # pylint: disable=W0621
try:
rpki.irdb.models.ca_certificate_lifetime = rpki.sundial.timedelta.parse(
cfg.get("bpki_ca_certificate_lifetime", section = "rpkic"))
except rpki.config.ConfigParser.Error:
pass
try:
rpki.irdb.models.ee_certificate_lifetime = rpki.sundial.timedelta.parse(
cfg.get("bpki_ee_certificate_lifetime", section = "rpkic"))
except rpki.config.ConfigParser.Error:
pass
try:
rpki.irdb.models.crl_interval = rpki.sundial.timedelta.parse(
cfg.get("bpki_crl_interval", section = "rpkic"))
except rpki.config.ConfigParser.Error:
pass
import django.core.management
django.core.management.call_command("syncdb", verbosity = 0, load_initial_data = False)
self.zoo = rpki.irdb.Zookeeper(cfg = cfg, handle = self.handle, logstream = sys.stdout)
def help_overview(self):
"""
Show program __doc__ string. Perhaps there's some clever way to
do this using the textwrap module, but for now something simple
and crude will suffice.
"""
for line in __doc__.splitlines(True):
self.stdout.write(" " * 4 + line)
self.stdout.write("\n")
def irdb_handle_complete(self, manager, text, line, begidx, endidx):
return [obj.handle for obj in manager.all() if obj.handle and obj.handle.startswith(text)]
def do_select_identity(self, arg):
"""
Select an identity handle for use with later commands.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting handle of new selected entity")
self.zoo.reset_identity(argv[0])
def complete_select_identity(self, *args):
return self.irdb_handle_complete(rpki.irdb.ResourceHolderCA.objects, *args)
def do_initialize(self, arg):
"""
Initialize an RPKI installation. This command reads the
configuration file, creates the BPKI and EntityDB directories,
generates the initial BPKI certificates, and creates an XML file
describing the resource-holding aspect of this RPKI installation.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
rootd_case = self.zoo.run_rootd and self.zoo.handle == self.zoo.cfg.get("handle")
r = self.zoo.initialize()
r.save("%s.identity.xml" % self.zoo.handle,
None if rootd_case else sys.stdout)
if rootd_case:
r = self.zoo.configure_rootd()
if r is not None:
r.save("%s.%s.repository-request.xml" % (self.zoo.handle, self.zoo.handle), sys.stdout)
self.zoo.write_bpki_files()
def do_create_identity(self, arg):
"""
Create a new resource-holding entity. Argument is the handle of
the entity to create. Returns XML file describing the new
resource holder.
This command is idempotent: calling it for a resource holder which
already exists returns the existing identity.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting handle of new entity")
self.zoo.reset_identity(argv[0])
r = self.zoo.initialize_resource_bpki()
r.save("%s.identity.xml" % self.zoo.handle, sys.stdout)
def do_initialize_server_bpki(self, arg):
"""
Initialize server BPKI portion of an RPKI installation. Reads
server configuration from configuration file and creates the
server BPKI objects needed to start daemons.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.initialize_server_bpki()
self.zoo.write_bpki_files()
def do_update_bpki(self, arg):
"""
Update BPKI certificates. Assumes an existing RPKI installation.
Basic plan here is to reissue all BPKI certificates we can, right
now. In the long run we might want to be more clever about only
touching ones that need maintenance, but this will do for a start.
We also reissue CRLs for all CAs.
Most likely this should be run under cron.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.update_bpki()
self.zoo.write_bpki_files()
try:
self.zoo.synchronize_bpki()
except Exception, e:
print "Couldn't push updated BPKI material into daemons: %s" % e
def do_configure_child(self, arg):
"""
Configure a new child of this RPKI entity, given the child's XML
identity file as an input. This command extracts the child's data
from the XML, cross-certifies the child's resource-holding BPKI
certificate, and generates an XML file describing the relationship
between the child and this parent, including this parent's BPKI
data and up-down protocol service URI.
"""
child_handle = None
valid_until = None
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, valid_until)
r.save("%s.%s.parent-response.xml" % (self.zoo.handle, child_handle), sys.stdout)
self.zoo.synchronize_ca()
def do_delete_child(self, arg):
"""
Delete a child of this RPKI entity.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting handle of child to delete")
try:
self.zoo.delete_child(argv[0])
self.zoo.synchronize_ca()
except rpki.irdb.ResourceHolderCA.DoesNotExist:
print "No such resource holder \"%s\"" % self.zoo.handle
except rpki.irdb.Child.DoesNotExist:
print "No such child \"%s\"" % argv[0]
def complete_delete_child(self, *args):
return self.irdb_handle_complete(self.zoo.resource_ca.children, *args)
def do_configure_parent(self, arg):
"""
Configure a new parent of this RPKI entity, given the output of
the parent's configure_child command as input. This command reads
the parent's response XML, extracts the parent's BPKI and service
URI information, cross-certifies the parent's BPKI data into this
entity's BPKI, and checks for offers or referrals of publication
service. If a publication offer or referral is present, we
generate a request-for-service message to that repository, in case
the user wants to avail herself of the referral or offer.
We do NOT attempt automatic synchronization with rpkid at the
completion of this command, because synchronization at this point
will usually fail due to the repository not being set up yet. If
you know what you are doing and for some reason really want to
synchronize here, run the synchronize command yourself.
"""
parent_handle = None
opts, argv = getopt.getopt(arg.split(), "", ["parent_handle="])
for o, a in opts:
if o == "--parent_handle":
parent_handle = a
if len(argv) != 1:
raise BadCommandSyntax("Expecting filename of parental response XML")
r, parent_handle = self.zoo.configure_parent(argv[0], parent_handle)
r.save("%s.%s.repository-request.xml" % (self.zoo.handle, parent_handle), sys.stdout)
def do_delete_parent(self, arg):
"""
Delete a parent of this RPKI entity.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting handle of parent to delete")
try:
self.zoo.delete_parent(argv[0])
self.zoo.synchronize_ca()
except rpki.irdb.ResourceHolderCA.DoesNotExist:
print "No such resource holder \"%s\"" % self.zoo.handle
except rpki.irdb.Parent.DoesNotExist:
print "No such parent \"%s\"" % argv[0]
def complete_delete_parent(self, *args):
return self.irdb_handle_complete(self.zoo.resource_ca.parents, *args)
def do_configure_root(self, arg):
"""
Configure the current resource holding identity as a root (ie,
configure it to talk to rootd as (one of) its parent(s). Returns
repository request XML file like configure_parent does.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
r = self.zoo.configure_rootd()
if r is not None:
r.save("%s.%s.repository-request.xml" % (self.zoo.handle, self.zoo.handle), sys.stdout)
self.zoo.write_bpki_files()
def do_delete_root(self, arg):
"""
Delete association with local RPKI root as parent of the current
entity (ie, tell this rpkid <self/> to stop talking to rootd).
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
try:
self.zoo.delete_rootd()
self.zoo.synchronize_ca()
except rpki.irdb.ResourceHolderCA.DoesNotExist:
print "No such resource holder \"%s\"" % self.zoo.handle
except rpki.irdb.Rootd.DoesNotExist:
print "No associated rootd"
def do_configure_publication_client(self, arg):
"""
Configure publication server to know about a new client, given the
client's request-for-service message as input. This command reads
the client's request for service, cross-certifies the client's
BPKI data, and generates a response message containing the
repository's BPKI data and service URI.
"""
sia_base = None
flat = False
opts, argv = getopt.getopt(arg.split(), "", ["flat", "sia_base="])
for o, a in opts:
if o == "--flat":
flat = True
elif o == "--sia_base":
sia_base = a
if len(argv) != 1:
raise BadCommandSyntax("Expecting filename for publication client request XML")
r, client_handle = self.zoo.configure_publication_client(argv[0], sia_base, flat)
r.save("%s.repository-response.xml" % client_handle.replace("/", "."), sys.stdout)
try:
self.zoo.synchronize_pubd()
except rpki.irdb.Repository.DoesNotExist:
pass
def do_delete_publication_client(self, arg):
"""
Delete a publication client of this RPKI entity.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting handle of client to delete")
try:
self.zoo.delete_publication_client(argv[0])
self.zoo.synchronize_pubd()
except rpki.irdb.ResourceHolderCA.DoesNotExist:
print "No such resource holder \"%s\"" % self.zoo.handle
except rpki.irdb.Client.DoesNotExist:
print "No such client \"%s\"" % argv[0]
def complete_delete_publication_client(self, *args):
return self.irdb_handle_complete(self.zoo.server_ca.clients, *args)
def do_configure_repository(self, arg):
"""
Configure a publication repository for this RPKI entity, given the
repository's response to our request-for-service message as input.
This command reads the repository's response, extracts and
cross-certifies the BPKI data and service URI, and links the
repository data with the corresponding parent data in our local
database.
"""
parent_handle = None
opts, argv = getopt.getopt(arg.split(), "", ["parent_handle="])
for o, a in opts:
if o == "--parent_handle":
parent_handle = a
if len(argv) != 1:
raise BadCommandSyntax("Expecting filename for repository response XML")
self.zoo.configure_repository(argv[0], parent_handle)
self.zoo.synchronize_ca()
def do_delete_repository(self, arg):
"""
Delete a repository of this RPKI entity.
This should check that the XML file it's deleting really is a
repository, but doesn't, yet.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting handle of repository to delete")
try:
self.zoo.delete_repository(argv[0])
self.zoo.synchronize_ca()
except rpki.irdb.ResourceHolderCA.DoesNotExist:
print "No such resource holder \"%s\"" % self.zoo.handle
except rpki.irdb.Repository.DoesNotExist:
print "No such repository \"%s\"" % argv[0]
def complete_delete_repository(self, *args):
return self.irdb_handle_complete(self.zoo.resource_ca.repositories, *args)
def do_delete_identity(self, arg):
"""
Delete the current RPKI identity (rpkid <self/> object).
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
try:
self.zoo.delete_self()
self.zoo.synchronize_deleted_ca()
except rpki.irdb.ResourceHolderCA.DoesNotExist:
print "No such resource holder \"%s\"" % self.zoo.handle
def do_delete_self(self, arg):
print "This is a deprecated alias for the \"delete_identity\" command."
self.do_delete_identity(arg)
def do_renew_child(self, arg):
"""
Update validity period for one child entity.
"""
valid_until = None
opts, argv = getopt.getopt(arg.split(), "", ["valid_until"])
for o, a in opts:
if o == "--valid_until":
valid_until = a
if len(argv) != 1:
raise BadCommandSyntax("Expecting handle of child to renew")
self.zoo.renew_children(argv[0], valid_until)
self.zoo.synchronize_ca()
if self.autosync:
self.zoo.run_rpkid_now()
def complete_renew_child(self, *args):
return self.irdb_handle_complete(self.zoo.resource_ca.children, *args)
def do_renew_all_children(self, arg):
"""
Update validity period for all child entities.
"""
valid_until = None
opts, argv = getopt.getopt(arg.split(), "", ["valid_until"])
for o, a in opts:
if o == "--valid_until":
valid_until = a
if argv:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.renew_children(None, valid_until)
self.zoo.synchronize_ca()
if self.autosync:
self.zoo.run_rpkid_now()
def do_load_prefixes(self, arg):
"""
Load prefixes into IRDB from CSV file.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting filename of prefixes CSV")
self.zoo.load_prefixes(argv[0], True)
if self.autosync:
self.zoo.run_rpkid_now()
def do_show_child_resources(self, arg):
"""
Show resources assigned to children.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
for child in self.zoo.resource_ca.children.all():
resources = child.resource_bag
print "Child:", child.handle
if resources.asn:
print " ASN:", resources.asn
if resources.v4:
print " IPv4:", resources.v4
if resources.v6:
print " IPv6:", resources.v6
def do_show_roa_requests(self, arg):
"""
Show ROA requests.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
for roa_request in self.zoo.resource_ca.roa_requests.all():
prefixes = roa_request.roa_prefix_bag
print "ASN: ", roa_request.asn
if prefixes.v4:
print " IPv4:", prefixes.v4
if prefixes.v6:
print " IPv6:", prefixes.v6
def do_show_ghostbuster_requests(self, arg):
"""
Show Ghostbuster requests.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
for ghostbuster_request in self.zoo.resource_ca.ghostbuster_requests.all():
print "Parent:", ghostbuster_request.parent or "*"
print ghostbuster_request.vcard
def do_show_received_resources(self, arg):
"""
Show resources received by this entity from its parent(s).
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
for pdu in self.zoo.call_rpkid(
rpki.left_right.list_received_resources_elt.make_pdu(self_handle = self.zoo.handle)):
print "Parent: ", pdu.parent_handle
print " notBefore:", pdu.notBefore
print " notAfter: ", pdu.notAfter
print " URI: ", pdu.uri
print " SIA URI: ", pdu.sia_uri
print " AIA URI: ", pdu.aia_uri
print " ASN: ", pdu.asn
print " IPv4: ", pdu.ipv4
print " IPv6: ", pdu.ipv6
def do_show_published_objects(self, arg):
"""
Show published objects.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
for pdu in self.zoo.call_rpkid(
rpki.left_right.list_published_objects_elt.make_pdu(self_handle = self.zoo.handle)):
track = rpki.x509.uri_dispatch(pdu.uri)(Base64 = pdu.obj).tracking_data(pdu.uri)
child = pdu.child_handle
if child is None:
print track
else:
print track, child
def do_load_asns(self, arg):
"""
Load ASNs into IRDB from CSV file.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting filename of ASNs CSV")
self.zoo.load_asns(argv[0], True)
if self.autosync:
self.zoo.run_rpkid_now()
def do_load_roa_requests(self, arg):
"""
Load ROA requests into IRDB from CSV file.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting filename of ROAs CSV")
self.zoo.load_roa_requests(argv[0])
if self.autosync:
self.zoo.run_rpkid_now()
def do_load_ghostbuster_requests(self, arg):
"""
Load Ghostbuster requests into IRDB from file.
"""
argv = arg.split()
if len(argv) != 1:
raise BadCommandSyntax("Expecting filename of Ghostbuster vCard(s)")
self.zoo.load_ghostbuster_requests(argv[0])
if self.autosync:
self.zoo.run_rpkid_now()
def do_synchronize(self, arg):
"""
Whack daemons to match IRDB.
This command may be replaced by implicit synchronization embedded
in of other commands, haven't decided yet.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.synchronize()
def do_force_publication(self, arg):
"""
Whack rpkid to force (re)publication of everything.
This is not usually necessary, as rpkid automatically publishes
changes it makes, but this command can be useful occasionally when
a fault or configuration error has left rpkid holding data which
it has not been able to publish.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.publish_world_now()
def do_force_reissue(self, arg):
"""
Whack rpkid to force reissuance of everything.
This is not usually necessary, as rpkid reissues automatically
objects automatically as needed, but this command can be useful
occasionally when a fault or configuration error has prevented
rpkid from reissuing when it should have.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.reissue()
def do_up_down_rekey(self, arg):
"""
Initiate a "rekey" operation: tell rpkid to generate new keys for
each certificate issued to it via the up-down protocol.
This is the first stage of a key rollover operation. You will
need to follow it up later with a "revoke" operation to clean up
the old keys
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.rekey()
def do_up_down_revoke(self, arg):
"""
Initiate a "revoke" operation: tell rpkid to clean up old keys
formerly used by certificates issued to it via the up-down
protocol.
This is the cleanup stage of a key rollover operation.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.revoke()
def do_revoke_forgotten(self, arg):
"""
Initiate a "revoke_forgotten" operation: tell rpkid to ask its
parent to revoke certificates for which rpkid does not know the
private keys. This should never happen during ordinary operation,
but can happen if rpkid is misconfigured or its database has been
damaged, so we need a way to resynchronize rpkid with its parent
in such cases. We could do this automatically, but as we don't
know the precise cause of the failure we don't know if it's
recoverable locally (eg, from an SQL backup), so we require a
manual trigger before discarding possibly-useful certificates.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.revoke_forgotten()
def do_clear_all_sql_cms_replay_protection(self, arg):
"""
Tell rpkid and pubd to clear replay protection for all SQL-based
entities. This is a fairly blunt instrument, but as we don't
expect this to be necessary except in the case of gross
misconfiguration, it should suffice
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
self.zoo.clear_all_sql_cms_replay_protection()
def do_version(self, arg):
"""
Show current software version number.
"""
if arg:
raise BadCommandSyntax("This command takes no arguments")
print rpki.version.VERSION
|