This PR refactors the ciecplib.x509.write_cert() function with some refactoring.
ciecplib.x509.write_cert()