Merge pull request #820 from brendanzagaeski/master
[mono.git] / mcs / class / System / System.Security.Cryptography.X509Certificates / X509Certificate2.cs
1 //
2 // System.Security.Cryptography.X509Certificate2 class
3 //
4 // Author:
5 //      Sebastien Pouliot  <sebastien@ximian.com>
6 //
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 // Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 #if SECURITY_DEP
31
32 #if MONOTOUCH
33 using Mono.Security;
34 using Mono.Security.Cryptography;
35 using MX = Mono.Security.X509;
36 #else
37 extern alias MonoSecurity;
38
39 using MonoSecurity::Mono.Security;
40 using MonoSecurity::Mono.Security.Cryptography;
41 using MX = MonoSecurity::Mono.Security.X509;
42 #endif
43
44 #endif
45
46 using System.IO;
47 using System.Text;
48
49 namespace System.Security.Cryptography.X509Certificates {
50
51 #if NET_4_0
52         [Serializable]
53 #endif
54         public class X509Certificate2 : X509Certificate {
55 #if !SECURITY_DEP
56                 // Used in Mono.Security HttpsClientStream
57                 public X509Certificate2 (byte[] rawData)
58                 {
59                 }
60 #endif
61 #if SECURITY_DEP
62                 private bool _archived;
63                 private X509ExtensionCollection _extensions;
64                 private string _name = String.Empty;
65                 private string _serial;
66                 private PublicKey _publicKey;
67                 private X500DistinguishedName issuer_name;
68                 private X500DistinguishedName subject_name;
69                 private Oid signature_algorithm;
70
71                 private MX.X509Certificate _cert;
72
73                 private static string empty_error = Locale.GetText ("Certificate instance is empty.");
74
75                 // constructors
76
77                 public X509Certificate2 ()
78                 {
79                         _cert = null;
80                 }
81
82                 public X509Certificate2 (byte[] rawData)
83                 {
84                         Import (rawData, (string)null, X509KeyStorageFlags.DefaultKeySet);
85                 }
86
87                 public X509Certificate2 (byte[] rawData, string password)
88                 {
89                         Import (rawData, password, X509KeyStorageFlags.DefaultKeySet);
90                 }
91
92                 public X509Certificate2 (byte[] rawData, SecureString password)
93                 {
94                         Import (rawData, password, X509KeyStorageFlags.DefaultKeySet);
95                 }
96
97                 public X509Certificate2 (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
98                 {
99                         Import (rawData, password, keyStorageFlags);
100                 }
101
102                 public X509Certificate2 (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
103                 {
104                         Import (rawData, password, keyStorageFlags);
105                 }
106
107                 public X509Certificate2 (string fileName)
108                 {
109                         Import (fileName, String.Empty, X509KeyStorageFlags.DefaultKeySet);
110                 }
111
112                 public X509Certificate2 (string fileName, string password)
113                 {
114                         Import (fileName, password, X509KeyStorageFlags.DefaultKeySet);
115                 }
116
117                 public X509Certificate2 (string fileName, SecureString password)
118                 {
119                         Import (fileName, password, X509KeyStorageFlags.DefaultKeySet);
120                 }
121
122                 public X509Certificate2 (string fileName, string password, X509KeyStorageFlags keyStorageFlags)
123                 {
124                         Import (fileName, password, keyStorageFlags);
125                 }
126
127                 public X509Certificate2 (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
128                 {
129                         Import (fileName, password, keyStorageFlags);
130                 }
131
132                 public X509Certificate2 (IntPtr handle) : base (handle) 
133                 {
134                         _cert = new MX.X509Certificate (base.GetRawCertData ());
135                 }
136
137                 public X509Certificate2 (X509Certificate certificate) 
138                         : base (certificate)
139                 {
140                         _cert = new MX.X509Certificate (base.GetRawCertData ());
141                 }
142
143                 // properties
144
145                 public bool Archived {
146                         get {
147                                 if (_cert == null)
148                                         throw new CryptographicException (empty_error);
149                                 return _archived;
150                         }
151                         set {
152                                 if (_cert == null)
153                                         throw new CryptographicException (empty_error);
154                                 _archived = value;
155                         }
156                 }
157
158                 public X509ExtensionCollection Extensions {
159                         get {
160                                 if (_cert == null)
161                                         throw new CryptographicException (empty_error);
162                                 if (_extensions == null)
163                                         _extensions = new X509ExtensionCollection (_cert);
164                                 return _extensions;
165                         }
166                 }
167
168                 public string FriendlyName {
169                         get {
170                                 if (_cert == null)
171                                         throw new CryptographicException (empty_error);
172                                 return _name;
173                         }
174                         set {
175                                 if (_cert == null)
176                                         throw new CryptographicException (empty_error);
177                                 _name = value;
178                         }
179                 }
180
181                 // FIXME - Could be more efficient
182                 public bool HasPrivateKey {
183                         get { return PrivateKey != null; }
184                 }
185
186                 public X500DistinguishedName IssuerName {
187                         get {
188                                 if (_cert == null)
189                                         throw new CryptographicException (empty_error);
190                                 if (issuer_name == null)
191                                         issuer_name = new X500DistinguishedName (_cert.GetIssuerName ().GetBytes ());
192                                 return issuer_name;
193                         }
194                 } 
195
196                 public DateTime NotAfter {
197                         get {
198                                 if (_cert == null)
199                                         throw new CryptographicException (empty_error);
200                                 return _cert.ValidUntil.ToLocalTime ();
201                         }
202                 }
203
204                 public DateTime NotBefore {
205                         get {
206                                 if (_cert == null)
207                                         throw new CryptographicException (empty_error);
208                                 return _cert.ValidFrom.ToLocalTime ();
209                         }
210                 }
211
212                 public AsymmetricAlgorithm PrivateKey {
213                         get {
214                                 if (_cert == null)
215                                         throw new CryptographicException (empty_error);
216                                 try {
217                                         if (_cert.RSA != null) {
218                                                 RSACryptoServiceProvider rcsp = _cert.RSA as RSACryptoServiceProvider;
219                                                 if (rcsp != null)
220                                                         return rcsp.PublicOnly ? null : rcsp;
221
222                                                 RSAManaged rsam = _cert.RSA as RSAManaged;
223                                                 if (rsam != null)
224                                                         return rsam.PublicOnly ? null : rsam;
225
226                                                 _cert.RSA.ExportParameters (true);
227                                                 return _cert.RSA;
228                                         } else if (_cert.DSA != null) {
229                                                 DSACryptoServiceProvider dcsp = _cert.DSA as DSACryptoServiceProvider;
230                                                 if (dcsp != null)
231                                                         return dcsp.PublicOnly ? null : dcsp;
232
233                                                 _cert.DSA.ExportParameters (true);
234                                                 return _cert.DSA;
235                                         }
236                                 }
237                                 catch {
238                                 }
239                                 return null;
240                         }
241                         set {
242                                 if (_cert == null)
243                                         throw new CryptographicException (empty_error);
244
245                                 // allow NULL so we can "forget" the key associated to the certificate
246                                 // e.g. in case we want to export it in another format (see bug #396620)
247                                 if (value == null) {
248                                         _cert.RSA = null;
249                                         _cert.DSA = null;
250                                 } else  if (value is RSA)
251                                         _cert.RSA = (RSA) value;
252                                 else if (value is DSA)
253                                         _cert.DSA = (DSA) value;
254                                 else
255                                         throw new NotSupportedException ();
256                         }
257                 } 
258
259                 public PublicKey PublicKey {
260                         get { 
261                                 if (_cert == null)
262                                         throw new CryptographicException (empty_error);
263
264                                 if (_publicKey == null) {
265                                         try {
266                                                 _publicKey = new PublicKey (_cert);
267                                         }
268                                         catch (Exception e) {
269                                                 string msg = Locale.GetText ("Unable to decode public key.");
270                                                 throw new CryptographicException (msg, e);
271                                         }
272                                 }
273                                 return _publicKey;
274                         }
275                 } 
276
277                 public byte[] RawData {
278                         get {
279                                 if (_cert == null)
280                                         throw new CryptographicException (empty_error);
281
282                                 return base.GetRawCertData ();
283                         }
284                 } 
285
286                 public string SerialNumber {
287                         get { 
288                                 if (_cert == null)
289                                         throw new CryptographicException (empty_error);
290
291                                 if (_serial == null) {
292                                         StringBuilder sb = new StringBuilder ();
293                                         byte[] serial = _cert.SerialNumber;
294                                         for (int i=serial.Length - 1; i >= 0; i--)
295                                                 sb.Append (serial [i].ToString ("X2"));
296                                         _serial = sb.ToString ();
297                                 }
298                                 return _serial; 
299                         }
300                 } 
301
302                 public Oid SignatureAlgorithm {
303                         get {
304                                 if (_cert == null)
305                                         throw new CryptographicException (empty_error);
306
307                                 if (signature_algorithm == null)
308                                         signature_algorithm = new Oid (_cert.SignatureAlgorithm);
309                                 return signature_algorithm;
310                         }
311                 } 
312
313                 public X500DistinguishedName SubjectName {
314                         get {
315                                 if (_cert == null)
316                                         throw new CryptographicException (empty_error);
317
318                                 if (subject_name == null)
319                                         subject_name = new X500DistinguishedName (_cert.GetSubjectName ().GetBytes ());
320                                 return subject_name;
321                         }
322                 } 
323
324                 public string Thumbprint {
325                         get { return base.GetCertHashString (); }
326                 } 
327
328                 public int Version {
329                         get {
330                                 if (_cert == null)
331                                         throw new CryptographicException (empty_error);
332                                 return _cert.Version;
333                         }
334                 }
335
336                 // methods
337
338                 [MonoTODO ("always return String.Empty for UpnName, DnsFromAlternativeName and UrlName")]
339                 public string GetNameInfo (X509NameType nameType, bool forIssuer) 
340                 {
341                         switch (nameType) {
342                         case X509NameType.SimpleName:
343                                 if (_cert == null)
344                                         throw new CryptographicException (empty_error);
345                                 // return CN= or, if missing, the first part of the DN
346                                 ASN1 sn = forIssuer ? _cert.GetIssuerName () : _cert.GetSubjectName ();
347                                 ASN1 dn = Find (commonName, sn);
348                                 if (dn != null)
349                                         return GetValueAsString (dn);
350                                 if (sn.Count == 0)
351                                         return String.Empty;
352                                 ASN1 last_entry = sn [sn.Count - 1];
353                                 if (last_entry.Count == 0)
354                                         return String.Empty;
355                                 return GetValueAsString (last_entry [0]);
356                         case X509NameType.EmailName:
357                                 // return the E= part of the DN (if present)
358                                 ASN1 e = Find (email, forIssuer ? _cert.GetIssuerName () : _cert.GetSubjectName ());
359                                 if (e != null)
360                                         return GetValueAsString (e);
361                                 return String.Empty;
362                         case X509NameType.UpnName:
363                                 // FIXME - must find/create test case
364                                 return String.Empty;
365                         case X509NameType.DnsName:
366                                 // return the CN= part of the DN (if present)
367                                 ASN1 cn = Find (commonName, forIssuer ? _cert.GetIssuerName () : _cert.GetSubjectName ());
368                                 if (cn != null)
369                                         return GetValueAsString (cn);
370                                 return String.Empty;
371                         case X509NameType.DnsFromAlternativeName:
372                                 // FIXME - must find/create test case
373                                 return String.Empty;
374                         case X509NameType.UrlName:
375                                 // FIXME - must find/create test case
376                                 return String.Empty;
377                         default:
378                                 throw new ArgumentException ("nameType");
379                         }
380                 }
381
382                 static byte[] commonName = { 0x55, 0x04, 0x03 };
383                 static byte[] email = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01 };
384
385                 private ASN1 Find (byte[] oid, ASN1 dn)
386                 {
387                         if (dn.Count == 0)
388                                 return null;
389
390                         // process SET
391                         for (int i = 0; i < dn.Count; i++) {
392                                 ASN1 set = dn [i];
393                                 for (int j = 0; j < set.Count; j++) {
394                                         ASN1 pair = set [j];
395                                         if (pair.Count != 2)
396                                                 continue;
397
398                                         ASN1 poid = pair [0];
399                                         if (poid == null)
400                                                 continue;
401
402                                         if (poid.CompareValue (oid))
403                                                 return pair;
404                                 }
405                         }
406                         return null;
407                 }
408
409                 private string GetValueAsString (ASN1 pair)
410                 {
411                         if (pair.Count != 2)
412                                 return String.Empty;
413
414                         ASN1 value = pair [1];
415                         if ((value.Value == null) || (value.Length == 0))
416                                 return String.Empty;
417
418                         if (value.Tag == 0x1E) {
419                                 // BMPSTRING
420                                 StringBuilder sb = new StringBuilder ();
421                                 for (int j = 1; j < value.Value.Length; j += 2)
422                                         sb.Append ((char)value.Value [j]);
423                                 return sb.ToString ();
424                         } else {
425                                 return Encoding.UTF8.GetString (value.Value);
426                         }
427                 }
428
429                 private MX.X509Certificate ImportPkcs12 (byte[] rawData, string password)
430                 {
431                         MX.PKCS12 pfx = (password == null) ? new MX.PKCS12 (rawData) : new MX.PKCS12 (rawData, password);
432                         if (pfx.Certificates.Count == 0) {
433                                 // no certificate was found
434                                 return null;
435                         } else if (pfx.Keys.Count == 0) {
436                                 // no key were found - pick the first certificate
437                                 return pfx.Certificates [0];
438                         } else {
439                                 // find the certificate that match the first key
440                                 MX.X509Certificate cert = null;
441                                 var keypair = (pfx.Keys [0] as AsymmetricAlgorithm);
442                                 string pubkey = keypair.ToXmlString (false);
443                                 foreach (var c in pfx.Certificates) {
444                                         if (((c.RSA != null) && (pubkey == c.RSA.ToXmlString (false))) ||
445                                                 ((c.DSA != null) && (pubkey == c.DSA.ToXmlString (false)))) {
446                                                 cert = c;
447                                                 break;
448                                         }
449                                 }
450                                 if (cert == null) {
451                                         cert = pfx.Certificates [0]; // no match, pick first certificate without keys
452                                 } else {
453                                         cert.RSA = (keypair as RSA);
454                                         cert.DSA = (keypair as DSA);
455                                 }
456                                 return cert;
457                         }
458                 }
459
460                 public override void Import (byte[] rawData) 
461                 {
462                         Import (rawData, (string)null, X509KeyStorageFlags.DefaultKeySet);
463                 }
464
465                 [MonoTODO ("missing KeyStorageFlags support")]
466                 public override void Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
467                 {
468                         MX.X509Certificate cert = null;
469                         if (password == null) {
470                                 try {
471                                         cert = new MX.X509Certificate (rawData);
472                                 }
473                                 catch (Exception e) {
474                                         try {
475                                                 cert = ImportPkcs12 (rawData, null);
476                                         }
477                                         catch {
478                                                 string msg = Locale.GetText ("Unable to decode certificate.");
479                                                 // inner exception is the original (not second) exception
480                                                 throw new CryptographicException (msg, e);
481                                         }
482                                 }
483                         } else {
484                                 // try PKCS#12
485                                 try {
486                                         cert = ImportPkcs12 (rawData, password);
487                                 }
488                                 catch {
489                                         // it's possible to supply a (unrequired/unusued) password
490                                         // fix bug #79028
491                                         cert = new MX.X509Certificate (rawData);
492                                 }
493                         }
494                         // we do not have to fully re-decode the certificate since X509Certificate does not deal with keys
495                         if (cert != null) {
496                                 base.Import (cert.RawData, (string) null, keyStorageFlags);
497                                 _cert = cert; // becuase base call will call Reset!
498                         }
499                 }
500
501                 [MonoTODO ("SecureString is incomplete")]
502                 public override void Import (byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
503                 {
504                         Import (rawData, (string) null, keyStorageFlags);
505                 }
506
507                 public override void Import (string fileName) 
508                 {
509                         byte[] rawData = File.ReadAllBytes (fileName);
510                         Import (rawData, (string)null, X509KeyStorageFlags.DefaultKeySet);
511                 }
512
513                 [MonoTODO ("missing KeyStorageFlags support")]
514                 public override void Import (string fileName, string password, X509KeyStorageFlags keyStorageFlags) 
515                 {
516                         byte[] rawData = File.ReadAllBytes (fileName);
517                         Import (rawData, password, keyStorageFlags);
518                 }
519
520                 [MonoTODO ("SecureString is incomplete")]
521                 public override void Import (string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags) 
522                 {
523                         byte[] rawData = File.ReadAllBytes (fileName);
524                         Import (rawData, (string)null, keyStorageFlags);
525                 }
526
527                 public override void Reset () 
528                 {
529                         _cert = null;
530                         _archived = false;
531                         _extensions = null;
532                         _name = String.Empty;
533                         _serial = null;
534                         _publicKey = null;
535                         issuer_name = null;
536                         subject_name = null;
537                         signature_algorithm = null;
538                         base.Reset ();
539                 }
540
541                 public override string ToString ()
542                 {
543                         if (_cert == null)
544                                 return "System.Security.Cryptography.X509Certificates.X509Certificate2";
545
546                         return base.ToString (true);
547                 }
548
549                 public override string ToString (bool verbose)
550                 {
551                         if (_cert == null)
552                                 return "System.Security.Cryptography.X509Certificates.X509Certificate2";
553
554                         // the non-verbose X509Certificate2 == verbose X509Certificate
555                         if (!verbose)
556                                 return base.ToString (true);
557
558                         string nl = Environment.NewLine;
559                         StringBuilder sb = new StringBuilder ();
560                         sb.AppendFormat ("[Version]{0}  V{1}{0}{0}", nl, Version);
561                         sb.AppendFormat ("[Subject]{0}  {1}{0}{0}", nl, Subject);
562                         sb.AppendFormat ("[Issuer]{0}  {1}{0}{0}", nl, Issuer);
563                         sb.AppendFormat ("[Serial Number]{0}  {1}{0}{0}", nl, SerialNumber);
564                         sb.AppendFormat ("[Not Before]{0}  {1}{0}{0}", nl, NotBefore);
565                         sb.AppendFormat ("[Not After]{0}  {1}{0}{0}", nl, NotAfter);
566                         sb.AppendFormat ("[Thumbprint]{0}  {1}{0}{0}", nl, Thumbprint);
567                         sb.AppendFormat ("[Signature Algorithm]{0}  {1}({2}){0}{0}", nl, SignatureAlgorithm.FriendlyName, 
568                                 SignatureAlgorithm.Value);
569
570                         AsymmetricAlgorithm key = PublicKey.Key;
571                         sb.AppendFormat ("[Public Key]{0}  Algorithm: ", nl);
572                         if (key is RSA)
573                                 sb.Append ("RSA");
574                         else if (key is DSA)
575                                 sb.Append ("DSA");
576                         else
577                                 sb.Append (key.ToString ());
578                         sb.AppendFormat ("{0}  Length: {1}{0}  Key Blob: ", nl, key.KeySize);
579                         AppendBuffer (sb, PublicKey.EncodedKeyValue.RawData);
580                         sb.AppendFormat ("{0}  Parameters: ", nl);
581                         AppendBuffer (sb, PublicKey.EncodedParameters.RawData);
582                         sb.Append (nl);
583
584                         return sb.ToString ();
585                 }
586
587                 private static void AppendBuffer (StringBuilder sb, byte[] buffer)
588                 {
589                         if (buffer == null)
590                                 return;
591                         for (int i=0; i < buffer.Length; i++) {
592                                 sb.Append (buffer [i].ToString ("x2"));
593                                 if (i < buffer.Length - 1)
594                                         sb.Append (" ");
595                         }
596                 }
597
598                 [MonoTODO ("by default this depends on the incomplete X509Chain")]
599                 public bool Verify ()
600                 {
601                         if (_cert == null)
602                                 throw new CryptographicException (empty_error);
603
604                         X509Chain chain = X509Chain.Create ();
605                         if (!chain.Build (this))
606                                 return false;
607                         // TODO - check chain and other stuff ???
608                         return true;
609                 }
610
611                 // static methods
612
613                 private static byte[] signedData = new byte[] { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02 };
614
615                 [MonoTODO ("Detection limited to Cert, Pfx, Pkcs12, Pkcs7 and Unknown")]
616                 public static X509ContentType GetCertContentType (byte[] rawData)
617                 {
618                         if ((rawData == null) || (rawData.Length == 0))
619                                 throw new ArgumentException ("rawData");
620
621                         X509ContentType type = X509ContentType.Unknown;
622                         try {
623                                 ASN1 data = new ASN1 (rawData);
624                                 if (data.Tag != 0x30) {
625                                         string msg = Locale.GetText ("Unable to decode certificate.");
626                                         throw new CryptographicException (msg);
627                                 }
628
629                                 if (data.Count == 0)
630                                         return type;
631
632                                 if (data.Count == 3) {
633                                         switch (data [0].Tag) {
634                                         case 0x30:
635                                                 // SEQUENCE / SEQUENCE / BITSTRING
636                                                 if ((data [1].Tag == 0x30) && (data [2].Tag == 0x03))
637                                                         type = X509ContentType.Cert;
638                                                 break;
639                                         case 0x02:
640                                                 // INTEGER / SEQUENCE / SEQUENCE
641                                                 if ((data [1].Tag == 0x30) && (data [2].Tag == 0x30))
642                                                         type = X509ContentType.Pkcs12;
643                                                 // note: Pfx == Pkcs12
644                                                 break;
645                                         }
646                                 }
647                                 // check for PKCS#7 (count unknown but greater than 0)
648                                 // SEQUENCE / OID (signedData)
649                                 if ((data [0].Tag == 0x06) && data [0].CompareValue (signedData))
650                                         type = X509ContentType.Pkcs7;
651                         }
652                         catch (Exception e) {
653                                 string msg = Locale.GetText ("Unable to decode certificate.");
654                                 throw new CryptographicException (msg, e);
655                         }
656
657                         return type;
658                 }
659
660                 [MonoTODO ("Detection limited to Cert, Pfx, Pkcs12 and Unknown")]
661                 public static X509ContentType GetCertContentType (string fileName)
662                 {
663                         if (fileName == null)
664                                 throw new ArgumentNullException ("fileName");
665                         if (fileName.Length == 0)
666                                 throw new ArgumentException ("fileName");
667
668                         byte[] data = File.ReadAllBytes (fileName);
669                         return GetCertContentType (data);
670                 }
671
672                 // internal stuff because X509Certificate2 isn't complete enough
673                 // (maybe X509Certificate3 will be better?)
674
675                 internal MX.X509Certificate MonoCertificate {
676                         get { return _cert; }
677                 }
678
679 #else
680                 // HACK - this ensure the type X509Certificate2 and PrivateKey property exists in the build before
681                 // Mono.Security.dll is built. This is required to get working client certificate in SSL/TLS
682                 public AsymmetricAlgorithm PrivateKey {
683                         get { return null; }
684                 }
685 #endif
686         }
687 }