gobgp
gobgp copied to clipboard
Verify RPKI with only AS Number?
Hi, is it possible to verify whether an AS Number is being protected by RPKI using this library, but without supplying route servers or RPKI servers? Just wondering. Thanks.
import rpki_client
def verify_asn_protected_by_rpki(asn):
try:
# Initialize the RPKI client
client = rpki_client.Client()
# Fetch the validated ROAs (Route Origin Authorizations)
roas = client.fetch_roas()
# Check if the given ASN is in any of the ROAs
for roa in roas:
if roa.asn == asn:
print(f"AS Number {asn} is protected by RPKI.")
return True
print(f"AS Number {asn} is NOT protected by RPKI.")
return False
except Exception as e:
print(f"An error occurred: {e}")
return False
# Example usage
asn_to_check = 12345
verify_asn_protected_by_rpki(asn_to_check)