예제 #1
0
        public async Task <IActionResult> SetCurrentCertSubject()
        {
            string subject = "";

            if (Request.HasCertificate(_options.Authentication.ClientCertHeader, out X509Certificate2 cert))
            {
                await _svc.AddAccountCertificate(User.GetSubjectId(), cert);

                Audit(AuditId.RegisteredCertificate);
            }
            else
            {
                if (Request.HasValidatedSubject(
                        _options.Authentication.ClientCertHeader,
                        _options.Authentication.ClientCertSubjectHeader,
                        _options.Authentication.ClientCertVerifyHeader,
                        out subject)
                    )
                {
                    await _svc.AddAccountValidatedSubject(User.GetSubjectId(), subject);

                    Audit(AuditId.RegisteredCertificate);
                }
                else
                {
                    throw new InvalidOperationException("CertificateNotVerified");
                }
            }

            return(Ok());
        }