Refactor certificate handling code -> cert_data.py