public void ClientAcceptUpgrade()
        {
            ServiceCredentials cred = new ServiceCredentials();
            X509Certificate2   cert =
                new X509Certificate2("Test/Resources/test.cer");

            cred.ServiceCertificate.Certificate = cert;
            X509CertificateEndpointIdentity ident =
                new X509CertificateEndpointIdentity(cert);
            StreamSecurityUpgradeProvider p = CreateClientProvider(cred, ident);

            p.Open();
            try
            {
                StreamSecurityUpgradeAcceptor a =
                    p.CreateUpgradeAcceptor()
                    as StreamSecurityUpgradeAcceptor;
                Assert.IsNotNull(a, "#1");
                SecurityMessageProperty prop =
                    a.GetRemoteSecurity();
                Assert.IsNull(prop, "#2"); // hmm
                Stream s = a.AcceptUpgrade(new MemoryStream(new byte [] { 1, 2, 3, 4, 5 }));
            }
            finally
            {
                p.Close();
            }
        }
Beispiel #2
0
		public void ClientAcceptUpgradeWithoutServiceCertificate ()
		{
			StreamSecurityUpgradeProvider p = CreateClientProvider ();
			Assert.IsNotNull (p, "#1");
			Assert.IsNull (p.Identity, "#2"); // not yet, before Open().
			p.Open ();
			StreamUpgradeAcceptor a = p.CreateUpgradeAcceptor ();
			try {
				Stream s = a.AcceptUpgrade (new MemoryStream (new byte [] {1, 2, 3, 4, 5}));
				Assert.Fail ("It should somehow raise an error."); // on Winfx it is unwise ArgumentNullException
			} catch (Exception) {
			} finally {
				p.Close ();
			}
		}