gobgp icon indicating copy to clipboard operation
gobgp copied to clipboard

Verify RPKI with only AS Number?

Open hazcod opened this issue 5 years ago • 1 comments

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.

hazcod avatar Apr 26 '20 12:04 hazcod

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)

ljluestc avatar Aug 11 '24 19:08 ljluestc