-/* Transport Security Layer (TLS)\r
- * Copyright (c) 2003 Carlos Guzmán Álvarez\r
- * \r
- * Permission is hereby granted, free of charge, to any person \r
- * obtaining a copy of this software and associated documentation \r
- * files (the "Software"), to deal in the Software without restriction, \r
- * including without limitation the rights to use, copy, modify, merge, \r
- * publish, distribute, sublicense, and/or sell copies of the Software, \r
- * and to permit persons to whom the Software is furnished to do so, \r
- * subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included \r
- * in all copies or substantial portions of the Software.\r
- * \r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, \r
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES \r
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND \r
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT \r
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, \r
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER \r
- * DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-using System;\r
-using System.Text;\r
-using System.Security.Cryptography.X509Certificates;\r
-\r
-namespace Mono.Security.Protocol.Tls\r
-{\r
- public sealed class TlsSessionSettings\r
- {\r
- #region FIELDS\r
-\r
- private string serverName;\r
- private int serverPort;\r
- private Encoding encoding;\r
- private TlsProtocol protocol;\r
- private TlsCompressionMethod compressionMethod;\r
- private X509CertificateCollection certificates;\r
- \r
- #endregion\r
-\r
- #region PROPERTIES\r
-\r
- public string ServerName\r
- {\r
- get { return serverName; }\r
- set { serverName = value; }\r
- }\r
-\r
- public int ServerPort\r
- {\r
- get { return serverPort; }\r
- set { serverPort = value; }\r
- }\r
-\r
- public Encoding Encoding\r
- {\r
- get { return encoding; }\r
- set { encoding = value; }\r
- }\r
-\r
- public TlsProtocol Protocol\r
- {\r
- get { return protocol; }\r
- set \r
- { \r
- if (value != TlsProtocol.Tls1 &&\r
- value != TlsProtocol.Ssl3)\r
- {\r
- throw new NotSupportedException("Specified protocol is not supported");\r
- }\r
- protocol = value; \r
- }\r
- }\r
-\r
- public TlsCompressionMethod CompressionMethod\r
- {\r
- get { return compressionMethod; }\r
- set \r
- { \r
- if (value != TlsCompressionMethod.None)\r
- {\r
- throw new NotSupportedException("Specified compression method is not supported");\r
- }\r
- compressionMethod = value; \r
- }\r
- }\r
-\r
- public X509CertificateCollection Certificates\r
- {\r
- get { return certificates; }\r
- set { certificates = value; }\r
- }\r
-\r
- #endregion\r
-\r
- #region CONSTRUCTORS\r
-\r
- public TlsSessionSettings()\r
- {\r
- this.protocol = TlsProtocol.Tls1;\r
- this.compressionMethod = TlsCompressionMethod.None;\r
- this.certificates = new X509CertificateCollection();\r
- this.serverName = "localhost";\r
- this.serverPort = 443;\r
- this.encoding = Encoding.Default;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol) : this()\r
- {\r
- this.Protocol = protocol;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, Encoding encoding) : this(protocol)\r
- {\r
- this.encoding = encoding;\r
- }\r
-\r
- public TlsSessionSettings(string serverName) : this()\r
- {\r
- this.serverName = serverName;\r
- }\r
-\r
- public TlsSessionSettings(string serverName, Encoding encoding) : this()\r
- {\r
- this.serverName = serverName;\r
- this.encoding = encoding;\r
- }\r
-\r
- public TlsSessionSettings(string serverName, int serverPort) : this()\r
- {\r
- this.serverName = serverName;\r
- this.serverPort = serverPort;\r
- }\r
-\r
- public TlsSessionSettings(string serverName, int serverPort, Encoding encoding) : this()\r
- {\r
- this.serverName = serverName;\r
- this.serverPort = serverPort;\r
- this.encoding = encoding;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, string serverName) : this(protocol)\r
- {\r
- this.serverName = serverName;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, string serverName, Encoding encoding) : this(protocol)\r
- {\r
- this.serverName = serverName;\r
- this.encoding = encoding;\r
- }\r
-\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, string serverName, int serverPort) : this(protocol)\r
- {\r
- this.serverName = serverName;\r
- this.serverPort = serverPort;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, string serverName, int serverPort, Encoding encoding) : this(protocol)\r
- {\r
- this.serverName = serverName;\r
- this.serverPort = serverPort;\r
- this.encoding = encoding;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates) : this(protocol)\r
- {\r
- this.certificates = certificates;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, Encoding encoding) : this(protocol)\r
- {\r
- this.certificates = certificates;\r
- this.encoding = encoding;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, string serverName, int serverPort) : this(protocol)\r
- {\r
- this.certificates = certificates;\r
- this.serverName = serverName;\r
- this.serverPort = serverPort;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, string serverName, int serverPort, Encoding encoding) : this(protocol)\r
- {\r
- this.certificates = certificates;\r
- this.serverName = serverName;\r
- this.serverPort = serverPort;\r
- this.encoding = encoding;\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates) \r
- : this(protocol, new X509CertificateCollection(certificates))\r
- {\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, Encoding encoding) \r
- : this(protocol, new X509CertificateCollection(certificates), encoding)\r
- {\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, string serverName, int serverPort) : \r
- this(protocol, new X509CertificateCollection(certificates), serverName, serverPort)\r
- {\r
- }\r
-\r
- public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, string serverName, int serverPort, Encoding encoding) : \r
- this(protocol, new X509CertificateCollection(certificates), serverName, serverPort, encoding)\r
- {\r
- }\r
-\r
- #endregion\r
- }\r
-}\r
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003 Carlos Guzmán Álvarez
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.Text;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Protocol.Tls
+{
+ public sealed class TlsSessionSettings
+ {
+ #region FIELDS
+
+ private string serverName;
+ private int serverPort;
+ private Encoding encoding;
+ private TlsProtocol protocol;
+ private TlsCompressionMethod compressionMethod;
+ private X509CertificateCollection certificates;
+
+ #endregion
+
+ #region PROPERTIES
+
+ public string ServerName
+ {
+ get { return serverName; }
+ set { serverName = value; }
+ }
+
+ public int ServerPort
+ {
+ get { return serverPort; }
+ set { serverPort = value; }
+ }
+
+ public Encoding Encoding
+ {
+ get { return encoding; }
+ set { encoding = value; }
+ }
+
+ public TlsProtocol Protocol
+ {
+ get { return protocol; }
+ set
+ {
+ if (value != TlsProtocol.Tls1 &&
+ value != TlsProtocol.Ssl3)
+ {
+ throw new NotSupportedException("Specified protocol is not supported");
+ }
+ protocol = value;
+ }
+ }
+
+ public TlsCompressionMethod CompressionMethod
+ {
+ get { return compressionMethod; }
+ set
+ {
+ if (value != TlsCompressionMethod.None)
+ {
+ throw new NotSupportedException("Specified compression method is not supported");
+ }
+ compressionMethod = value;
+ }
+ }
+
+ public X509CertificateCollection Certificates
+ {
+ get { return certificates; }
+ set { certificates = value; }
+ }
+
+ #endregion
+
+ #region CONSTRUCTORS
+
+ public TlsSessionSettings()
+ {
+ this.protocol = TlsProtocol.Tls1;
+ this.compressionMethod = TlsCompressionMethod.None;
+ this.certificates = new X509CertificateCollection();
+ this.serverName = "localhost";
+ this.serverPort = 443;
+ this.encoding = Encoding.Default;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol) : this()
+ {
+ this.Protocol = protocol;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, Encoding encoding) : this(protocol)
+ {
+ this.encoding = encoding;
+ }
+
+ public TlsSessionSettings(string serverName) : this()
+ {
+ this.serverName = serverName;
+ }
+
+ public TlsSessionSettings(string serverName, Encoding encoding) : this()
+ {
+ this.serverName = serverName;
+ this.encoding = encoding;
+ }
+
+ public TlsSessionSettings(string serverName, int serverPort) : this()
+ {
+ this.serverName = serverName;
+ this.serverPort = serverPort;
+ }
+
+ public TlsSessionSettings(string serverName, int serverPort, Encoding encoding) : this()
+ {
+ this.serverName = serverName;
+ this.serverPort = serverPort;
+ this.encoding = encoding;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, string serverName) : this(protocol)
+ {
+ this.serverName = serverName;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, string serverName, Encoding encoding) : this(protocol)
+ {
+ this.serverName = serverName;
+ this.encoding = encoding;
+ }
+
+
+ public TlsSessionSettings(TlsProtocol protocol, string serverName, int serverPort) : this(protocol)
+ {
+ this.serverName = serverName;
+ this.serverPort = serverPort;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, string serverName, int serverPort, Encoding encoding) : this(protocol)
+ {
+ this.serverName = serverName;
+ this.serverPort = serverPort;
+ this.encoding = encoding;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates) : this(protocol)
+ {
+ this.certificates = certificates;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, Encoding encoding) : this(protocol)
+ {
+ this.certificates = certificates;
+ this.encoding = encoding;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, string serverName, int serverPort) : this(protocol)
+ {
+ this.certificates = certificates;
+ this.serverName = serverName;
+ this.serverPort = serverPort;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, string serverName, int serverPort, Encoding encoding) : this(protocol)
+ {
+ this.certificates = certificates;
+ this.serverName = serverName;
+ this.serverPort = serverPort;
+ this.encoding = encoding;
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates)
+ : this(protocol, new X509CertificateCollection(certificates))
+ {
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, Encoding encoding)
+ : this(protocol, new X509CertificateCollection(certificates), encoding)
+ {
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, string serverName, int serverPort) :
+ this(protocol, new X509CertificateCollection(certificates), serverName, serverPort)
+ {
+ }
+
+ public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, string serverName, int serverPort, Encoding encoding) :
+ this(protocol, new X509CertificateCollection(certificates), serverName, serverPort, encoding)
+ {
+ }
+
+ #endregion
+ }
+}