THRIFT-2347 C# TLS Transport based on THRIFT-181
Client: C#
Patch: Beat Käslin
This closes #104
commit 21c33abd59a2333c48722933c6894d8ed145e638
Author: Beat Kaeslin <beat.kaeslin@siemens.com>
Date: 2014-04-16T14:07:58Z
Add TLS transport for C#
commit 60a0baa1797b0ef0ea6f8c21e5b81a78cdfcdf16
Author: Beat Kaeslin <beat.kaeslin@siemens.com>
Date: 2014-04-17T06:23:57Z
csharp tests moved to the end
diff --git a/lib/csharp/test/ThriftTest/TestClient.cs b/lib/csharp/test/ThriftTest/TestClient.cs
index ba2d4d0..593169f 100644
--- a/lib/csharp/test/ThriftTest/TestClient.cs
+++ b/lib/csharp/test/ThriftTest/TestClient.cs
@@ -30,6 +30,7 @@
public class TestClient
{
private static int numIterations = 1;
+ private static string protocol = "";
public static void Execute(string[] args)
{
@@ -39,7 +40,7 @@
int port = 9090;
string url = null, pipe = null;
int numThreads = 1;
- bool buffered = false, framed = false;
+ bool buffered = false, framed = false, encrypted = false;
try
{
@@ -81,6 +82,21 @@
{
numThreads = Convert.ToInt32(args[++i]);
}
+ else if (args[i] == "-ssl")
+ {
+ encrypted = true;
+ Console.WriteLine("Using encrypted transport");
+ }
+ else if (args[i] == "-compact")
+ {
+ protocol = "compact";
+ Console.WriteLine("Using compact protocol");
+ }
+ else if (args[i] == "-json")
+ {
+ protocol = "json";
+ Console.WriteLine("Using JSON protocol");
+ }
}
}
catch (Exception e)
@@ -88,8 +104,6 @@
Console.WriteLine(e.StackTrace);
}
-
-
//issue tests on separate threads simultaneously
Thread[] threads = new Thread[numThreads];
DateTime start = DateTime.Now;
@@ -101,17 +115,22 @@
{
// endpoint transport
TTransport trans = null;
- if( pipe != null)
+ if (pipe != null)
trans = new TNamedPipeClientTransport(pipe);
else
- trans = new TSocket(host, port);
-
+ {
+ if (encrypted)
+ trans = new TTLSSocket(host, port, "../../../../../keys/client.pem");
+ else
+ trans = new TSocket(host, port);
+ }
+
// layered transport
if (buffered)
trans = new TBufferedTransport(trans as TStreamTransport);
if (framed)
trans = new TFramedTransport(trans);
-
+
//ensure proper open/close of transport
trans.Open();
trans.Close();
@@ -151,9 +170,15 @@
public static void ClientTest(TTransport transport)
{
- TBinaryProtocol binaryProtocol = new TBinaryProtocol(transport);
+ TProtocol proto;
+ if (protocol == "compact")
+ proto = new TCompactProtocol(transport);
+ else if (protocol == "json")
+ proto = new TJSONProtocol(transport);
+ else
+ proto = new TBinaryProtocol(transport);
- ThriftTest.Client client = new ThriftTest.Client(binaryProtocol);
+ ThriftTest.Client client = new ThriftTest.Client(proto);
try
{
if (!transport.IsOpen)
@@ -430,7 +455,6 @@
}
Console.WriteLine("}");
-
sbyte arg0 = 1;
int arg1 = 2;
long arg2 = long.MaxValue;