(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Security / Mono.Security.Protocol.Tls / TlsClientSettings.cs
blob0b200e27abe2e295010ab78dc6353693b9c689aa
1 // Transport Security Layer (TLS)
2 // Copyright (c) 2003-2004 Carlos Guzman Alvarez
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 using System;
26 using System.Text;
27 using System.Security.Cryptography.X509Certificates;
28 using Mono.Security.Cryptography;
29 using X509 = Mono.Security.X509;
31 namespace Mono.Security.Protocol.Tls
33 internal sealed class TlsClientSettings
35 #region Fields
37 private string targetHost;
38 private X509CertificateCollection certificates;
39 private SecurityCompressionType compressionMethod;
40 private X509Certificate clientCertificate;
41 private RSAManaged certificateRSA;
43 #endregion
45 #region Properties
47 public string TargetHost
49 get { return this.targetHost; }
50 set { this.targetHost = value; }
53 public X509CertificateCollection Certificates
55 get { return this.certificates; }
56 set { this.certificates = value; }
59 public X509Certificate ClientCertificate
61 get { return this.clientCertificate; }
62 set
64 this.clientCertificate = value;
65 this.UpdateCertificateRSA();
69 public RSAManaged CertificateRSA
71 get { return this.certificateRSA; }
75 public SecurityCompressionType CompressionMethod
77 get { return this.compressionMethod; }
78 set
80 if (value != SecurityCompressionType.None)
82 throw new NotSupportedException("Specified compression method is not supported");
84 this.compressionMethod = value;
89 #endregion
91 #region Constructors
93 public TlsClientSettings()
95 this.compressionMethod = SecurityCompressionType.None;
96 this.certificates = new X509CertificateCollection();
97 this.targetHost = String.Empty;
100 #endregion
102 #region Methods
104 public void UpdateCertificateRSA()
106 if (this.clientCertificate == null)
108 this.certificateRSA = null;
110 else
112 X509.X509Certificate cert = new X509.X509Certificate(this.clientCertificate.GetRawCertData());
114 this.certificateRSA = new RSAManaged(
115 cert.RSA.KeySize);
117 this.certificateRSA.ImportParameters(
118 cert.RSA.ExportParameters(false));
122 #endregion