Added proper X509 certificate handling.