Beispiel #1
0
        public void TestAuthServers()
        {
            string[] plainServers = new string[] {
                "nats://*****:*****@localhost:1224"
                };

                opts.Servers = authServers;

                using (IConnection c = new ConnectionFactory().CreateConnection(opts))
                {
                    Assert.Equal(authServers[1], c.ConnectedUrl);
                }
            }
        }
Beispiel #2
0
        public void TestNKey()
        {
            using (utils.CreateServerWithConfig("nkey.conf"))
            {
                Options opts = ConnectionFactory.GetDefaultOptions();

                // See nkey.conf
                opts.SetNkey("UCKKTOZV72L3NITTGNOCRDZUI5H632XCT4ZWPJBC2X3VEY72KJUWEZ2Z", "./config/certs/user.nk");
                new ConnectionFactory().CreateConnection(opts).Close();
            }
        }
 public void TestAuthSuccess()
 {
     using (NATSServer s = util.CreateServerWithConfig("auth_1222.conf"))
     {
         IConnection c = new ConnectionFactory().CreateConnection("nats://*****:*****@localhost:1222");
         c.Close();
     }
 }
Beispiel #4
0
        public void TestTlsSuccessWithCert()
        {
            using (NATSServer srv = util.CreateServerWithConfig("tls_1222_verify.conf"))
            {
                Options opts = util.DefaultTestOptions;
                opts.Secure = true;
                opts.Url    = "nats://localhost:1222";
                opts.TLSRemoteCertificationValidationCallback = verifyServerCert;

                // .NET requires the private key and cert in the
                //  same file. 'client.pfx' is generated from:
                //
                // openssl pkcs12 -export -out client.pfx
                //    -inkey client-key.pem -in client-cert.pem
                X509Certificate2 cert = new X509Certificate2(
                    UnitTestUtilities.GetFullCertificatePath("client.pfx"), "password");

                opts.AddCertificate(cert);

                using (IConnection c = new ConnectionFactory().CreateConnection(opts))
                {
                    using (ISyncSubscription s = c.SubscribeSync("foo"))
                    {
                        c.Publish("foo", null);
                        c.Flush();
                        Msg m = s.NextMessage();
                    }
                }
            }
        }