THRIFT-3361 Improve C# library
Client: C#
Patch: Nobuaki Sukegawa <nsukeg@gmail.com>

This closes #630
diff --git a/lib/csharp/src/Transport/TTLSSocket.cs b/lib/csharp/src/Transport/TTLSSocket.cs
index 5652556..833b792 100644
--- a/lib/csharp/src/Transport/TTLSSocket.cs
+++ b/lib/csharp/src/Transport/TTLSSocket.cs
@@ -33,43 +33,43 @@
         /// <summary>
         /// Internal TCP Client
         /// </summary>
-        private TcpClient client = null;
+        private TcpClient client;
 
         /// <summary>
         /// The host
         /// </summary>
-        private string host = null;
+        private string host;
 
         /// <summary>
         /// The port
         /// </summary>
-        private int port = 0;
+        private int port;
 
         /// <summary>
         /// The timeout for the connection
         /// </summary>
-        private int timeout = 0;
+        private int timeout;
 
         /// <summary>
         /// Internal SSL Stream for IO
         /// </summary>
-        private SslStream secureStream = null;
+        private SslStream secureStream;
 
         /// <summary>
         /// Defines wheter or not this socket is a server socket<br/>
         /// This is used for the TLS-authentication
         /// </summary>
-        private bool isServer = false;
+        private bool isServer;
 
         /// <summary>
         /// The certificate
         /// </summary>
-        private X509Certificate certificate = null;
+        private X509Certificate certificate;
 
         /// <summary>
         /// User defined certificate validator.
         /// </summary>
-        private RemoteCertificateValidationCallback certValidator = null;
+        private RemoteCertificateValidationCallback certValidator;
 
         /// <summary>
         /// The function to determine which certificate to use.
@@ -96,6 +96,10 @@
             this.certValidator = certValidator;
             this.localCertificateSelectionCallback = localCertificateSelectionCallback;
             this.isServer = isServer;
+            if (isServer && certificate == null)
+            {
+                throw new ArgumentException("TTLSSocket needs certificate to be used for server", "certificate");
+            }
 
             if (IsOpen)
             {
@@ -133,7 +137,7 @@
         public TTLSSocket(
             string host,
             int port,
-            X509Certificate certificate,
+            X509Certificate certificate = null,
             RemoteCertificateValidationCallback certValidator = null,
             LocalCertificateSelectionCallback localCertificateSelectionCallback = null)
             : this(host, port, 0, certificate, certValidator, localCertificateSelectionCallback)
@@ -315,7 +319,8 @@
                 else
                 {
                     // Client authentication
-                    this.secureStream.AuthenticateAsClient(host, new X509CertificateCollection { certificate }, SslProtocols.Tls, true);
+                    X509CertificateCollection certs = certificate != null ?  new X509CertificateCollection { certificate } : new X509CertificateCollection();
+                    this.secureStream.AuthenticateAsClient(host, certs, SslProtocols.Tls, true);
                 }
             }
             catch (Exception)