#!/usr/bin/env python3 """ Simple test to debug the encryption issue. """ import os import sys from pathlib import Path # Load environment env_local_path = Path(".env.local") if env_local_path.exists(): print(f"Loading environment from {env_local_path}") with open(env_local_path, 'r') as f: for line in f: line = line.strip() if line and not line.startswith('#') and '=' in line: key, value = line.split('=', 1) os.environ[key.strip()] = value.strip() print("Environment loaded:") print(f"ENCRYPTION_PASSWORD: {os.getenv('ENCRYPTION_PASSWORD', 'NOT_SET')[:20]}...") print(f"RPA_SERVER_URL: {os.getenv('RPA_SERVER_URL', 'NOT_SET')}") print(f"RPA_AUTH_DISABLED: {os.getenv('RPA_AUTH_DISABLED', 'NOT_SET')}") # Add paths sys.path.insert(0, str(Path(__file__).parent / "agent_v0")) try: from user_config import load_user_config config = load_user_config() print(f"\nAgent config:") print(f" encryption_password: {config.get('encryption_password')}") print(f" enable_encryption: {config.get('enable_encryption')}") # This is the key issue - when encryption_password is None, # the agent uses session_id as password if config.get('encryption_password') is None: print(" -> Agent will use session-based password (rpa_vision_v3_)") server_password = os.getenv("ENCRYPTION_PASSWORD", "rpa_vision_v3_default_key") agent_password_type = "session-based" if config.get('encryption_password') is None else "fixed" print(f"\nPassword mismatch:") print(f" Agent uses: {agent_password_type} password") print(f" Server uses: fixed password from ENCRYPTION_PASSWORD") print(f" This causes 'Padding invalide' error when server tries to decrypt") except Exception as e: print(f"Error: {e}") import traceback traceback.print_exc()