Refactored restoreCert to remove Java dependency.