Use X509 API to generate certificate file.