Moved X509 functions to separate procedures.