diff options
author | Rob Austein <sra@hactrn.net> | 2010-02-24 01:31:33 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2010-02-24 01:31:33 +0000 |
commit | f7910efde4e2ea3e40b00dac0b80124ac7c22448 (patch) | |
tree | 13054596153dcd2b7d82d67871e6790a9a6fae03 /rpkid/rpki/x509.py | |
parent | 2ecbf67ba206151a866a23f2861e0da26f393126 (diff) |
Checkpoint
svn path=/rpkid/rpki/async.py; revision=3006
Diffstat (limited to 'rpkid/rpki/x509.py')
-rw-r--r-- | rpkid/rpki/x509.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/rpkid/rpki/x509.py b/rpkid/rpki/x509.py index 85f04c73..3cf9739a 100644 --- a/rpkid/rpki/x509.py +++ b/rpkid/rpki/x509.py @@ -102,6 +102,18 @@ class PEM_converter(object): b64 = b64[64:] return pem + b64 + "\n" + self.e + "\n" +def _find_xia_uri(extension, name): + """ + Find a rsync URI in an SIA or AIA extension. + Returns the URI if found, otherwise None. + """ + oid = rpki.oids.name2oid[name] + + for method, location in extension: + if method == oid and location[0] == "uri" and location[1].startswith("rsync://"): + return location[1] + return None + class DER_object(object): """ Virtual class to hold a generic DER object. @@ -262,6 +274,20 @@ class DER_object(object): """ return (self.get_POWpkix().getExtension(rpki.oids.name2oid["subjectInfoAccess"]) or ((), 0, None))[2] + def get_sia_directory_uri(self): + """ + Get SIA directory (id-ad-caRepository) URI from this object. + Only works for subclasses that support getExtension(). + """ + return _find_xia_uri(self.get_SIA(), "id-ad-caRepository") + + def get_sia_manifest_uri(self): + """ + Get SIA manifest (id-ad-rpkiManifest) URI from this object. + Only works for subclasses that support getExtension(). + """ + return _find_xia_uri(self.get_SIA(), "id-ad-rpkiManifest") + def get_AIA(self): """ Get the SIA extension from this object. Only works for subclasses @@ -269,6 +295,13 @@ class DER_object(object): """ return (self.get_POWpkix().getExtension(rpki.oids.name2oid["authorityInfoAccess"]) or ((), 0, None))[2] + def get_aia_uri(self): + """ + Get AIA (id-ad-caIssuers) URI from this object. + Only works for subclasses that support getExtension(). + """ + return _find_xia_uri(self.get_AIA(), "id-ad-caIssuers") + def get_basicConstraints(self): """ Get the basicConstraints extension from this object. Only works |