Throw exception if certificate is not valid.