Add x509_certificate and encode methods to utilities and use them throughout utilities