public unsafe void X509CredentialsRoundTripTest2() { var x509Credentials = new X509Credentials { IssuerThumbprints = { "ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff" }, FindType = X509FindType.FindByThumbprint, FindValue = "ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff", }; var pinCollection = new PinCollection(); NativeX509CredentialConverter converter = new NativeX509CredentialConverter(x509Credentials); var nativeIntPtr = converter.ToNative(pinCollection); Assert.AreNotEqual(nativeIntPtr, IntPtr.Zero); var fromNative = X509Credentials.CreateFromNative((NativeTypes.FABRIC_X509_CREDENTIALS *)nativeIntPtr); Assert.AreEqual(x509Credentials.ProtectionLevel, fromNative.ProtectionLevel); Assert.AreEqual(x509Credentials.StoreName, fromNative.StoreName); Assert.AreEqual(x509Credentials.StoreLocation, fromNative.StoreLocation); Assert.AreEqual(x509Credentials.FindType, fromNative.FindType); Assert.AreEqual(x509Credentials.FindValue, fromNative.FindValue); Assert.AreEqual(x509Credentials.FindValueSecondary, fromNative.FindValueSecondary); Assert.IsTrue(x509Credentials.RemoteCommonNames.SequenceEqual(fromNative.RemoteCommonNames)); Assert.IsTrue(x509Credentials.IssuerThumbprints.SequenceEqual(fromNative.IssuerThumbprints)); Assert.IsTrue(x509Credentials.RemoteCertThumbprints.SequenceEqual(fromNative.RemoteCertThumbprints)); Assert.IsTrue(x509Credentials.RemoteX509Names.SequenceEqual(fromNative.RemoteX509Names)); Assert.IsTrue(x509Credentials.RemoteCertIssuers.SequenceEqual(fromNative.RemoteCertIssuers)); }
public unsafe void X509CredentialsRoundTripTest11() { var x509Credentials = new X509Credentials { FindType = X509FindType.FindByThumbprint, FindValue = "78 12 20 5a 39 d2 23 76 da a0 37 f0 5a ed e3 60 1a 7e 64 bf", ProtectionLevel = ProtectionLevel.Sign }; x509Credentials.RemoteX509Names.Add(new X509Name("name1", "1f ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff")); x509Credentials.RemoteX509Names.Add(new X509Name("name1", "2f ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff")); x509Credentials.RemoteX509Names.Add(new X509Name("name2", "3f ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff")); x509Credentials.RemoteX509Names.Add(new X509Name("name3", null)); var pinCollection = new PinCollection(); NativeX509CredentialConverter converter = new NativeX509CredentialConverter(x509Credentials); var nativeIntPtr = converter.ToNative(pinCollection); Assert.AreNotEqual(nativeIntPtr, IntPtr.Zero); var fromNative = X509Credentials.CreateFromNative((NativeTypes.FABRIC_X509_CREDENTIALS *)nativeIntPtr); Assert.AreEqual(x509Credentials.ProtectionLevel, fromNative.ProtectionLevel); Assert.AreEqual(x509Credentials.StoreName, fromNative.StoreName); Assert.AreEqual(x509Credentials.StoreLocation, fromNative.StoreLocation); Assert.AreEqual(x509Credentials.FindType, fromNative.FindType); Assert.AreEqual(x509Credentials.FindValue, fromNative.FindValue); Assert.AreEqual(x509Credentials.FindValueSecondary, fromNative.FindValueSecondary); Assert.IsTrue(x509Credentials.RemoteCommonNames.SequenceEqual(fromNative.RemoteCommonNames)); Assert.IsTrue(x509Credentials.IssuerThumbprints.SequenceEqual(fromNative.IssuerThumbprints)); Assert.IsTrue(x509Credentials.RemoteCertThumbprints.SequenceEqual(fromNative.RemoteCertThumbprints)); Assert.IsTrue(x509Credentials.RemoteX509Names.SequenceEqual(fromNative.RemoteX509Names)); Assert.IsTrue(x509Credentials.RemoteCertIssuers.SequenceEqual(fromNative.RemoteCertIssuers)); }