From: Sebastien Pouliot Date: Sun, 8 Oct 2006 16:06:08 +0000 (-0000) Subject: 2006-10-08 Sebastien Pouliot X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=e8cf1f347d19e6543cb8a6467715ffadb4e46056;p=mono.git 2006-10-08 Sebastien Pouliot * 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 --- diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog index 4d9e39b4ecf..eb3312cb2c5 100644 --- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog +++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog @@ -1,3 +1,8 @@ +2006-10-08 Sebastien Pouliot + + * X509Certificate.cs: Ensure we can load certificates from read-only + files (fix bug #79616). Refactored to avoid code duplication. + 2006-08-08 Sebastien Pouliot * X509Certificate.cs: A unrequired password can be supplied to the diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs index c226033ad20..69e201d2b05 100644 --- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs +++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs @@ -1,5 +1,5 @@ // -// X509Certificates.cs: Handles X.509 certificates. +// X509Certificate.cs: Handles X.509 certificates. // // Author: // Sebastien Pouliot @@ -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; + } } }