Added check for x509 certificate validity