Author: spouliot
Date: 2005-03-24 14:10:59 -0500 (Thu, 24 Mar 2005)
New Revision: 42230

Modified:
   
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
   
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
Log:
2005-03-24  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * X509Certificate.cs: Added Demand for UnmanagedCode to ctor(IntPtr).
        Return "empty" certificate when IntPtr.Zero is used with ctor(IntPtr).
        Don't wrap SecurityException inside COMException for Authenticode.



Modified: 
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
===================================================================
--- 
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog  
    2005-03-24 18:37:02 UTC (rev 42229)
+++ 
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog  
    2005-03-24 19:10:59 UTC (rev 42230)
@@ -1,3 +1,9 @@
+2005-03-24  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * X509Certificate.cs: Added Demand for UnmanagedCode to ctor(IntPtr).
+       Return "empty" certificate when IntPtr.Zero is used with ctor(IntPtr).
+       Don't wrap SecurityException inside COMException for Authenticode.
+
 2004-11-30  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * X509Certificate.cs: Added ComVisible attributes to match 2.0 October

Modified: 
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
===================================================================
--- 
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
     2005-03-24 18:37:02 UTC (rev 42229)
+++ 
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
     2005-03-24 19:10:59 UTC (rev 42230)
@@ -29,6 +29,7 @@
 
 using System.IO;
 using System.Runtime.InteropServices;
+using System.Security.Permissions;
 using System.Text;
 
 using Mono.Security;
@@ -123,6 +124,10 @@
                                byte[] cert = null; // must not confuse 
compiler about null ;)
                                return new X509Certificate (cert);
                        }
+                       catch (SecurityException) {
+                               // don't wrap SecurityException into a 
COMException
+                               throw;
+                       }
                        catch (Exception e) {
                                string msg = String.Format (Locale.GetText 
("Couldn't extract digital signature from {0}."), filename);
                                throw new COMException (msg, e);
@@ -145,12 +150,16 @@
                {
                }
        
+               [SecurityPermission (SecurityAction.Demand, UnmanagedCode = 
true)]
                public X509Certificate (IntPtr handle) 
                {
-                       CertificateContext cc = (CertificateContext) 
Marshal.PtrToStructure (handle, typeof (CertificateContext));
-                       byte[] data = new byte [cc.cbCertEncoded];
-                       Marshal.Copy (cc.pbCertEncoded, data, 0, 
(int)cc.cbCertEncoded);
-                       x509 = new Mono.Security.X509.X509Certificate (data);
+                       if (handle != IntPtr.Zero) {
+                               CertificateContext cc = (CertificateContext) 
Marshal.PtrToStructure (handle, typeof (CertificateContext));
+                               byte[] data = new byte [cc.cbCertEncoded];
+                               Marshal.Copy (cc.pbCertEncoded, data, 0, 
(int)cc.cbCertEncoded);
+                               x509 = new Mono.Security.X509.X509Certificate 
(data);
+                       }
+                       // IntPtr.Zero results in an "empty" certificate 
instance
                }
        
                public X509Certificate 
(System.Security.Cryptography.X509Certificates.X509Certificate cert) 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to