2006-10-08 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Sun, 8 Oct 2006 16:06:08 +0000 (16:06 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Sun, 8 Oct 2006 16:06:08 +0000 (16:06 -0000)
* X509Certificate.cs: Ensure we can load certificates from read-only
files (fix bug #79616). Refactored to avoid code duplication.

svn path=/trunk/mcs/; revision=66412

mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs

index 4d9e39b4ecf10bfbbe30dc0f9f619bfe7c663729..eb3312cb2c55cdbd41aa2488a8c588df9bf1c18c 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-08  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * X509Certificate.cs: Ensure we can load certificates from read-only
+       files (fix bug #79616). Refactored to avoid code duplication.
+
 2006-08-08  Sebastien Pouliot  <sebastien@ximian.com>
 
        * X509Certificate.cs: A unrequired password can be supplied to the 
index c226033ad20e0f0e33f393a09dc27565e9eea7ad..69e201d2b05c11b81357124d4d88a8cb873f4874 100644 (file)
@@ -1,5 +1,5 @@
 //
-// X509Certificates.cs: Handles X.509 certificates.
+// X509Certificate.cs: Handles X.509 certificates.
 //
 // Author:
 //     Sebastien Pouliot  <sebastien@ximian.com>
@@ -97,12 +97,7 @@ namespace System.Security.Cryptography.X509Certificates {
        
                public static X509Certificate CreateFromCertFile (string filename) 
                {
-                       byte[] data = null;
-                       using (FileStream fs = File.OpenRead (filename)) {
-                               data = new byte [fs.Length];
-                               fs.Read (data, 0, data.Length);
-                               fs.Close ();
-                       }
+                       byte[] data = Load (filename);
                        return new X509Certificate (data);
                }
        
@@ -581,17 +576,6 @@ namespace System.Security.Cryptography.X509Certificates {
                        Import (rawData, (string)null, keyStorageFlags);
                }
 
-               private byte[] Load (string fileName)
-               {
-                       byte[] data = null;
-                       using (FileStream fs = new FileStream (fileName, FileMode.Open)) {
-                               data = new byte [fs.Length];
-                               fs.Read (data, 0, data.Length);
-                               fs.Close ();
-                       }
-                       return data;
-               }
-
                [MonoTODO]
                void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
                {
@@ -610,5 +594,15 @@ namespace System.Security.Cryptography.X509Certificates {
                        get { return (IntPtr) 0; }
                }
 #endif
+               private static byte[] Load (string fileName)
+               {
+                       byte[] data = null;
+                       using (FileStream fs = File.OpenRead (fileName)) {
+                               data = new byte [fs.Length];
+                               fs.Read (data, 0, data.Length);
+                               fs.Close ();
+                       }
+                       return data;
+               }
        }
 }