Put KeyPairPersistence load into a try{}catch{} block.
[mono.git] / mcs / class / Mono.Security / Mono.Security.X509 / X509Store.cs
index c4bb4b99afc571ad78443cf986ac88853b898f7a..b22f1b5ae25e12fc20f9250a0e5e4a415b3a49a0 100644 (file)
@@ -236,8 +236,13 @@ namespace Mono.Security.X509 {
                                cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
                        KeyPairPersistence kpp = new KeyPairPersistence (cspParams);
 
-                       if (!kpp.Load ())
+                       try {
+                               if (!kpp.Load ())
+                                       return cert;
+                       }
+                       catch {
                                return cert;
+                       }
 
                        if (cert.RSA != null)
                                cert.RSA = new RSACryptoServiceProvider (cspParams);