2 // System.Security.Cryptography.X509Certificates.X509Chain
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 // Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com)
9 // Copyright (C) 2011 Xamarin Inc. (http://www.xamarin.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #if MONO_SECURITY_ALIAS
34 extern alias MonoSecurity;
35 using MX = MonoSecurity::Mono.Security.X509;
37 using MX = Mono.Security.X509;
40 using System.Collections;
43 namespace System.Security.Cryptography.X509Certificates {
45 public class X509Chain : IDisposable {
49 static X509ChainStatus[] Empty = new X509ChainStatus [0];
51 internal X509ChainImpl Impl {
53 X509Helper2.ThrowIfContextInvalid (impl);
58 internal bool IsValid {
59 get { return X509Helper2.IsValid (impl); }
62 internal void ThrowIfContextInvalid ()
64 X509Helper2.ThrowIfContextInvalid (impl);
74 public X509Chain (bool useMachineContext)
76 impl = X509Helper2.CreateChainImpl (useMachineContext);
79 internal X509Chain (X509ChainImpl impl)
81 X509Helper2.ThrowIfContextInvalid (impl);
85 [MonoTODO ("Mono's X509Chain is fully managed. All handles are invalid.")]
86 public X509Chain (IntPtr chainContext)
88 // CryptoAPI compatibility (unmanaged handle)
89 throw new NotSupportedException ();
94 [MonoTODO ("Mono's X509Chain is fully managed. Always returns IntPtr.Zero.")]
95 public IntPtr ChainContext {
97 if (impl != null && impl.IsValid)
103 public X509ChainElementCollection ChainElements {
104 get { return Impl.ChainElements; }
107 public X509ChainPolicy ChainPolicy {
108 get { return Impl.ChainPolicy; }
109 set { Impl.ChainPolicy = value; }
112 public X509ChainStatus[] ChainStatus {
113 get { return Impl.ChainStatus; }
118 [MonoTODO ("Not totally RFC3280 compliant, but neither is MS implementation...")]
119 public bool Build (X509Certificate2 certificate)
121 return Impl.Build (certificate);
131 public static X509Chain Create ()
134 return new X509Chain ();
136 return (X509Chain) CryptoConfig.CreateFromName ("X509Chain");
140 public void Dispose ()
143 GC.SuppressFinalize (this);
146 protected virtual void Dispose (bool disposing)
161 namespace System.Security.Cryptography.X509Certificates {
162 public class X509Chain {
163 public bool Build (X509Certificate2 cert)