Ejemplo n.º 1
0
 public void TestNoKey()
 {
     try {
         TLSClientEndPoint ep = new TLSClientEndPoint((TlsKeyPair)null);
         ep.Dispose();
         Assert.Fail("Should not have reached here.");
     }
     catch (ArgumentNullException e) {
         Assert.AreEqual(e.ParamName, "tlsKey");
     }
 }
Ejemplo n.º 2
0
        public void NoEndPoint()
        {
            TLSClientEndPoint ep  = new TLSClientEndPoint(PskOneKey);
            Request           req = new Request(Method.GET)
            {
                URI      = new Uri("coaps+tcp://localhost:5682/.well-known/core"),
                EndPoint = ep
            };

            ep.Start();

            req.Send();
            req.WaitForResponse(5000);
        }
Ejemplo n.º 3
0
        public void CoapURL()
        {
            TLSClientEndPoint ep  = new TLSClientEndPoint(PskOneKey);
            Request           req = new Request(Method.GET)
            {
                URI      = new Uri("coap://localhost/.well-known/core"),
                EndPoint = ep
            };

            ep.Start();

            try {
                req.Send();
                req.WaitForResponse(5000);
            }
            catch (Exception e) {
                Assert.AreEqual(e.Message, "Schema is incorrect for the end point");
            }
        }
Ejemplo n.º 4
0
        public void TestX509()
        {
            Uri uri = new Uri($"coaps+tcp://localhost:{_serverPort}/Hello1");
            TLSClientEndPoint client = new TLSClientEndPoint(X509Client);
            client.TlsEventHandler += ClientTlsEvents;
            client.Start();

            Request req = new Request(Method.GET)
            {
                URI = uri,
                EndPoint = client
            };

            req.Send();
            String txt = req.WaitForResponse(50000).ResponseText;
            Assert.AreEqual("Hello from CN=COSE EE Five", txt);
            client.Stop();

            Thread.Sleep(5000);

        }
Ejemplo n.º 5
0
        public void TlsTestPskEvents()
        {
            Uri uri = new Uri($"coaps+tcp://localhost:{_serverPort}/Hello1");
            TLSClientEndPoint client = new TLSClientEndPoint(PskOne);

            client.Start();

            Request req = new Request(Method.GET)
            {
                URI      = uri,
                EndPoint = client
            };

            req.Send();
            Response resp = req.WaitForResponse(50000);

            Assert.AreEqual(null, resp);
            client.Stop();

            TLSClientEndPoint client2 = new TLSClientEndPoint(PskTwo);

            client2.Start();
            Request req2 = new Request(Method.GET)
            {
                URI      = uri,
                EndPoint = client2
            };

            req2.Send();
            string txt = req2.WaitForResponse(50000).ResponseText;

            Assert.AreEqual("Hello from KeyTwo", txt);

            client2.Stop();

            Thread.Sleep(5000);
        }
Ejemplo n.º 6
0
 public void TestRpk()
 {
     TlsKeyPair        tlsKey = new TlsKeyPair(RpkOneKey.PublicKey(), RpkOneKey);
     TLSClientEndPoint ep     = new TLSClientEndPoint(RpkOneKey);
 }