public static void ValidateEmulatorChain(string alias, string deviceID, string root) { try { X509Certificate2 aliasCert = new X509Certificate2(); X509Certificate2 devIDCert = null; X509Certificate2 rootCert = new X509Certificate2(); rootCert.Import(Helpers.GetBytesFromPEM(root, "CERTIFICATE")); aliasCert = new X509Certificate2(Helpers.GetBytesFromPEM(alias, "CERTIFICATE")); devIDCert = new X509Certificate2(Helpers.GetBytesFromPEM(deviceID, "CERTIFICATE")); rootCert = new X509Certificate2(Helpers.GetBytesFromPEM(root, "CERTIFICATE")); var chain = new X509Chain { ChainPolicy = { RevocationMode = X509RevocationMode.NoCheck, RevocationFlag = X509RevocationFlag.ExcludeRoot, VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority } }; //chain.ChainPolicy.ExtraStore.Add(devIDCert); chain.ChainPolicy.ExtraStore.Add(rootCert); bool chainBuildSucceeded = chain.Build(aliasCert as X509Certificate2 ?? new X509Certificate2(aliasCert.Export(X509ContentType.Cert))); if (!chainBuildSucceeded) { foreach (var err in chain.ChainStatus) { Helpers.Notify($"Error:{err.StatusInformation.ToString()}", true); } } } catch (Exception e) { Helpers.Notify($"ValidateEmulatorChain error {e.ToString()}"); } }