Using self-signed certificates

I have this code:

X509Chain x509Chain = new X509Chain(); x509Chain.ChainPolicy.ExtraStore.Add(certificate1); x509Chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; x509Chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot; x509Chain.Build(certificate2); foreach (X509ChainElement x509ChainElement in x509Chain.ChainElements) { Log("Name: " + x509ChainElement.Certificate.GetNameInfo(X509NameType.SimpleName, false)); foreach (X509ChainStatus x509ChainStatus in x509ChainElement.ChainElementStatus) Log("status: " + x509ChainStatus.StatusInformation); if (x509ChainElement.ChainElementStatus.Length != 0 && (x509ChainElement.Certificate.Thumbprint != certificate1.Thumbprint))// || x509ChainElement.ChainElementStatus[0].Status != X509ChainStatusFlags.UntrustedRoot)) return false; } 

I can’t get him to install the certificate if he signed it (or at least I think it is not installed). In the status log message, I get the following:

Certificate chain processed, but completed in root certificate trusted by trust provider

How can I ignore this check?

+1
source share
1 answer

Configure the flags policy to enable AllowUnknownCertificateAuthority .

-one
source

All Articles