2010-04-07 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.ServiceModel / Mono.Security.Protocol.Tls / TlsServerSettings.cs
blobfec31752e76eb0b27eaf8765145088ac7108f420
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.Security.Cryptography;
28 using Mono.Security.Cryptography;
29 using Mono.Security.X509;
30 using Mono.Security.Protocol.Tls.Handshake;
32 namespace Mono.Security.Protocol.Tls
34 internal class TlsServerSettings
36 #region Fields
38 private X509CertificateCollection certificates;
39 private RSA certificateRSA;
40 private RSAParameters rsaParameters;
41 private byte[] signedParams;
42 private string[] distinguisedNames;
43 private bool serverKeyExchange;
44 private bool certificateRequest;
45 private ClientCertificateType[] certificateTypes;
47 #endregion
49 #region Properties
51 public bool ServerKeyExchange
53 get { return this.serverKeyExchange; }
54 set { this.serverKeyExchange = value; }
57 public X509CertificateCollection Certificates
59 get { return this.certificates; }
60 set { this.certificates = value; }
63 public RSA CertificateRSA
65 get { return this.certificateRSA; }
68 public RSAParameters RsaParameters
70 get { return this.rsaParameters; }
71 set { this.rsaParameters = value; }
74 public byte[] SignedParams
76 get { return this.signedParams; }
77 set { this.signedParams = value; }
80 public bool CertificateRequest
82 get { return this.certificateRequest; }
83 set { this.certificateRequest = value; }
86 public ClientCertificateType[] CertificateTypes
88 get { return this.certificateTypes; }
89 set { this.certificateTypes = value; }
92 public string[] DistinguisedNames
94 get { return this.distinguisedNames; }
95 set { this.distinguisedNames = value; }
98 #endregion
100 #region Constructors
102 public TlsServerSettings()
106 #endregion
108 #region Methods
110 public void UpdateCertificateRSA()
112 if (this.certificates == null ||
113 this.certificates.Count == 0)
115 this.certificateRSA = null;
117 else
119 this.certificateRSA = new RSAManaged(
120 this.certificates[0].RSA.KeySize);
122 this.certificateRSA.ImportParameters(
123 this.certificates[0].RSA.ExportParameters(false));
127 #endregion