Cleanup and fix X509Certificate.