Add x509 auth operation, refactor common code