aboutsummaryrefslogtreecommitdiff
path: root/scripts/rpki
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rpki')
-rw-r--r--scripts/rpki/exceptions.py6
-rw-r--r--scripts/rpki/left_right.py11
-rw-r--r--scripts/rpki/up_down.py9
3 files changed, 18 insertions, 8 deletions
diff --git a/scripts/rpki/exceptions.py b/scripts/rpki/exceptions.py
index 2819dff8..b5f0010f 100644
--- a/scripts/rpki/exceptions.py
+++ b/scripts/rpki/exceptions.py
@@ -49,3 +49,9 @@ class UpstreamError(Exception):
class ChildNotFound(Exception):
"""Could not find specified child in database."""
+
+class BSCNotFound(Exception):
+ """Could not find specified BSC in database."""
+
+class BadSender(Exception):
+ """Unexpected XML sender value."""
diff --git a/scripts/rpki/left_right.py b/scripts/rpki/left_right.py
index b9d96415..5fea299f 100644
--- a/scripts/rpki/left_right.py
+++ b/scripts/rpki/left_right.py
@@ -2,7 +2,7 @@
"""RPKI "left-right" protocol."""
-import base64, lxml.etree, time
+import base64, lxml.etree, time, traceback
import rpki.sax_utils, rpki.resource_set, rpki.x509, rpki.sql, rpki.exceptions
import rpki.https, rpki.up_down, rpki.relaxng
@@ -435,7 +435,7 @@ class parent_elt(data_elt):
"""
bsc = bsc_elt.sql_fetch(gctx, self.bsc_id)
if bsc is None:
- raise rpki.exceptions.NotFound, "Could not find BSC %s" % self.bsc_id
+ raise rpki.exceptions.BSCNotFound, "Could not find BSC %s" % self.bsc_id
q_msg = rpki.up_down.message_pdu.make_query(q_pdu)
q_elt = q_msg.toXML()
rpki.relaxng.up_down.assertValid(q_elt)
@@ -492,12 +492,12 @@ class child_elt(data_elt):
"""Outer layer of server handling for one up-down PDU from this child."""
bsc = bsc_elt.sql_fetch(gctx, self.bsc_id)
if bsc is None:
- raise rpki.exceptions.NotFound, "Could not find BSC %s" % self.bsc_id
+ raise rpki.exceptions.BSCNotFound, "Could not find BSC %s" % self.bsc_id
q_elt = rpki.cms.xml_verify(query, self.cms_ta)
rpki.relaxng.up_down.assertValid(q_elt)
q_msg = rpki.up_down.sax_handler.saxify(q_elt)
if q_msg.sender != str(self.child_id):
- raise rpki.exceptions.NotFound, "Unexpected XML sender %s" % q_msg.sender
+ raise rpki.exceptions.BadSender, "Unexpected XML sender %s" % q_msg.sender
try:
r_msg = q_msg.serve_top_level(gctx, self)
except Exception, data:
@@ -627,6 +627,7 @@ class list_resources_elt(base_elt):
element_name = "list_resources"
attributes = ("type", "self_id", "child_id", "valid_until", "as", "ipv4", "ipv6", "subject_name")
+ valid_until = None
def startElement(self, stack, name, attrs):
"""Handle <list_resources/> element."""
@@ -735,7 +736,7 @@ def irdb_query(gctx, self_id, child_id = None):
needed for the event-driven code that this function will need to become.
"""
- q_msg = msg_elt()
+ q_msg = msg()
q_msg.append(list_resources_elt())
q_msg[0].type = "query"
q_msg[0].self_id = self_id
diff --git a/scripts/rpki/up_down.py b/scripts/rpki/up_down.py
index 7b4065cb..a507203c 100644
--- a/scripts/rpki/up_down.py
+++ b/scripts/rpki/up_down.py
@@ -415,9 +415,12 @@ class error_response_pdu(base_elt):
def toXML(self):
"""Generate payload of "error_response" PDU."""
assert self.status in self.codes
- elt = self.make_elt("status")
- elt.text = str(self.status)
- return [elt]
+ status_elt = self.make_elt("status")
+ status_elt.text = str(self.status)
+ description_elt = self.make_elt("description")
+ description_elt.text = str(self.description)
+ description_elt.set("xml:lang", "en")
+ return [status_elt, description_elt]
def check_syntax(self):
"""Handle an error response. For the moment, just raise an