def METHOD_NAME(self):
    if self.KEY_FILE_PATH:
        with open(self.KEY_FILE_PATH, "rb") as key_file:
            data = key_file.read()
    elif self.KEY:
        data = self.KEY
    cert = x509.load_pem_x509_certificate(data, default_backend())
    public_key = cert.public_key()
    return public_key