Common code for manipulating X.509 certificates