public string GetRemoteIdentityName() { if (!this.IsValidContext) { return(String.Empty); } X509Certificate2 cert = this.RemoteCertificate; if (cert == null) { return(String.Empty); } return(SecurityUtils.GetCertificateId(cert)); }
internal bool TryValidate(X509Certificate2 certificate, out Exception exception) { using (X509Chain chain = new X509Chain(this.useMachineContext)) { chain.ChainPolicy = this.chainPolicy; if (!chain.Build(certificate)) { exception = new SecurityTokenValidationException(SR.GetString(SR.X509ChainBuildFail, SecurityUtils.GetCertificateId(certificate), GetChainStatusInformation(chain.ChainStatus))); return(false); } if (chain.ChainElements.Count > 1) //is not self-signed { chain.ChainPolicy = OidChainPolicy; X509Certificate2 cert = chain.ChainElements[1].Certificate; if (!chain.Build(cert)) { exception = new SecurityTokenValidationException(SR.GetString(SR.X509ChainBuildFail, SecurityUtils.GetCertificateId(certificate), GetChainStatusInformation(chain.ChainStatus))); return(false); } } exception = null; return(true); } }