draft-ietf-sidr-rfc6490-bis-03 defines a new format for TALs. This commit adds support for both old and new style TALs. --- bin/rpki/updateTA.py.in | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-)
diff --git a/bin/rpki/updateTA.py.in b/bin/rpki/updateTA.py.in index 146e54f..6c803df 100644 --- a/bin/rpki/updateTA.py.in +++ b/bin/rpki/updateTA.py.in @@ -223,21 +223,38 @@ def delete_other_TAs(keep_paths): def parse_TAL_file(tal_file): """Return [rsyncURI, subjectPublicKeyInfo] as a pair of strings.""" - f = open(tal_file, "r") - - # First non-blank line is the TA rsync URI - rsync_uri = None - while not rsync_uri: - rsync_uri = f.readline().strip() - - # Base64-encoded SubjectPublicKeyInfo is the rest of the file, - # with all whitespace removed. - words = [] - for line in f: - for w in line.strip().split(): - words.append(w) - pubkey_b64 = "".join(words) - return [rsync_uri, pubkey_b64] + with open(tal_file, "r") as f: + lines = f.readlines() + + rsync_uris = [] + pubkey_b64_words = [] + + if '\r\n' in lines or '\n' in lines: + # Parse as in draft-ietf-sidr-rfc6490-bis-03 + in_uri_section = True + for line in lines: + if in_uri_section: + if line in ('\r\n', '\n'): + in_uri_section = False + continue + elif line.lower().startswith('rsync://'): + rsync_uris.append(line.strip()) + else: + pubkey_b64_words.extend(line.split()) + + else: + # Parse as in RFC6490 + if lines[0].lower().startswith('rsync://'): + rsync_uris.append(lines[0].strip()) + for line in lines[1:]: + pubkey_b64_words.extend(line.split()) + + if not rsync_uris: + raise RuntimeError('TAL file has no rsync URIs: ' + tal_file) + elif not pubkey_b64_words: + raise RuntimeError('TAL file has no public key: ' + tal_file) + + return [rsync_uris[0], ''.join(pubkey_b64_words)] def compute_local_path(rsync_uri, local_repo_path): if rsync_uri.startswith("rsync://"): -- 1.9.1 ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ rpstir-devel mailing list rpstir-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpstir-devel