centralized the method to extract only the required key and certificate