Replace X509 macros with functions