コード例 #1
0
ファイル: TlssX509.cs プロジェクト: Com-AugustCellars/TCP
        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);

        }
コード例 #2
0
ファイル: TlssEvents.cs プロジェクト: Com-AugustCellars/TCP
        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);
        }