disable broken tests on net_4_0
[mcs.git] / class / corlib / Mono.Security.X509 / X509StoreManager.cs
blobd7b9c2c39fe49097c20792504c63734798cb5c2d
1 //
2 // X509StoreManager.cs: X.509 store manager.
3 //
4 // Author:
5 // Sebastien Pouliot <sebastien@ximian.com>
6 //
7 // (C) 2004 Novell (http://www.novell.com)
8 //
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System;
34 using System.Collections;
35 using System.IO;
37 using Mono.Security.X509.Extensions;
39 namespace Mono.Security.X509 {
41 #if INSIDE_CORLIB
42 internal
43 #else
44 public
45 #endif
46 sealed class X509StoreManager {
48 static private X509Stores _userStore;
49 static private X509Stores _machineStore;
51 private X509StoreManager ()
55 static public X509Stores CurrentUser {
56 get {
57 if (_userStore == null) {
58 string _userPath = Path.Combine (
59 Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
60 ".mono");
61 _userPath = Path.Combine (_userPath, "certs");
63 _userStore = new X509Stores (_userPath);
65 return _userStore;
69 static public X509Stores LocalMachine {
70 get {
71 if (_machineStore == null) {
72 string _machinePath = Path.Combine (
73 Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData),
74 ".mono");
75 _machinePath = Path.Combine (_machinePath, "certs");
77 _machineStore = new X509Stores (_machinePath);
79 return _machineStore;
83 // Merged stores collections
84 // we need to look at both the user and the machine (entreprise)
85 // certificates/CRLs when building/validating a chain
87 static public X509CertificateCollection IntermediateCACertificates {
88 get {
89 X509CertificateCollection intermediateCerts = new X509CertificateCollection ();
90 intermediateCerts.AddRange (CurrentUser.IntermediateCA.Certificates);
91 intermediateCerts.AddRange (LocalMachine.IntermediateCA.Certificates);
92 return intermediateCerts;
96 static public ArrayList IntermediateCACrls {
97 get {
98 ArrayList intermediateCRLs = new ArrayList ();
99 intermediateCRLs.AddRange (CurrentUser.IntermediateCA.Crls);
100 intermediateCRLs.AddRange (LocalMachine.IntermediateCA.Crls);
101 return intermediateCRLs;
105 static public X509CertificateCollection TrustedRootCertificates {
106 get {
107 X509CertificateCollection trustedCerts = new X509CertificateCollection ();
108 trustedCerts.AddRange (CurrentUser.TrustedRoot.Certificates);
109 trustedCerts.AddRange (LocalMachine.TrustedRoot.Certificates);
110 return trustedCerts;
114 static public ArrayList TrustedRootCACrls {
115 get {
116 ArrayList trustedCRLs = new ArrayList ();
117 trustedCRLs.AddRange (CurrentUser.TrustedRoot.Crls);
118 trustedCRLs.AddRange (LocalMachine.TrustedRoot.Crls);
119 return trustedCRLs;
123 static public X509CertificateCollection UntrustedCertificates {
124 get {
125 X509CertificateCollection untrustedCerts = new X509CertificateCollection ();
126 untrustedCerts.AddRange (CurrentUser.Untrusted.Certificates);
127 untrustedCerts.AddRange (LocalMachine.Untrusted.Certificates);
128 return untrustedCerts;