[Mono-bugs] [Bug 72742][Wis] Changed - RSACryptoServiceProvider fails to persist via CspProviderFlags.UseMachineKeyStore

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 18 Feb 2005 16:51:24 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien@ximian.com.


--- shadow/72742	2005-02-18 16:17:29.000000000 -0500
+++ shadow/72742.tmp.23200	2005-02-18 16:51:24.000000000 -0500
@@ -1,16 +1,16 @@
 Bug#: 72742
 Product: Mono: Class Libraries
 Version: 1.1
+OS: unknown
 OS Details: Fedora Core 3
-Status: NEW   
+Status: RESOLVED   
+Resolution: NOTABUG
+Severity: Unknown
 Priority: Wishlist
-Component: System.Security
+Component: CORLIB
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: met@uberstats.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
@@ -38,6 +38,44 @@
 Everytime unless I create the directory.
 Additional Information:
 The quick fix was to create /usr/share/.mono and /usr/share/.mono/keypairs
 as it didn't try and create them.  But the thing to note is my installation
 prefix is /usr/local/mono so /usr/share/.mono doesn't seem right either way.
+------- Additional Comments From sebastien@ximian.com  2005-02-18 16:51 -------
+The code _does_ try to create *and* protect the directory, however it
+failed to...
+_machinePath = Path.Combine (
+	Environment.GetFolderPath
+	".mono");
+_machinePath = Path.Combine (_machinePath, "keypairs");
+_machinePathExists = Directory.Exists (_machinePath);
+if (!_machinePathExists) {
+	try {
+		Directory.CreateDirectory (_machinePath);
+		ProtectMachine (_machinePath);
+		_machinePathExists = true;
+	}
+	catch (Exception e) {
+		string msg = Locale.GetText ("Could not create machine key store
+		throw new CryptographicException (String.Format (msg, _machinePath), e);
+	}
+Note: UnauthorizedAccessException means that the current user (running
+your application) couldn't create and/or protect required the directory.
+As the code also show the base directory to keep the machine keys is
+and has nothing to do with your prefix. This ensure that multiple Mono
+runtimes (e.g. 1.0/1.1) will share the same machine keypairs.
+That being said I discourage people from using the default persistance
+mechanism whenever possible (it's included for compatibility) and
+offer key management (creation, backup, replacement...) inside their