2006-09-20 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 20 Sep 2006 17:58:51 +0000 (17:58 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 20 Sep 2006 17:58:51 +0000 (17:58 -0000)
* SignedXml.cs : overwrite my fix with Gert's patch on #79454 to make it
  possible to handle multiple certificates.

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

mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog
mcs/class/System.Security/System.Security.Cryptography.Xml/SignedXml.cs

index 66f417a6deec29a1ce8ab58855f2bdf3a381111a..ddc0220a555a51b65c632f204f776d3d2a9d6289 100644 (file)
@@ -1,3 +1,8 @@
+2006-09-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SignedXml.cs : overwrite my fix with Gert's patch on #79454 to make it
+         possible to handle multiple certificates.
+
 2006-09-20  Atsushi Enomoto  <atsushi@ximian.com>
 
        * SignedXml.cs : handle KeyInfoX509Data in GetPublicKey(). Fixed #1 of
index 50718164a586ff2042f0aac8821cb35d6e1a72ef..4d30baa407f58959b45003717ba4fc06b8704c5f 100644 (file)
@@ -85,7 +85,10 @@ namespace System.Security.Cryptography.Xml {
                private XmlResolver xmlResolver = new XmlUrlResolver ();
 #endif
                private ArrayList manifests;
-               
+#if NET_2_0
+               private IEnumerator _x509Enumerator;
+#endif
+
                private static readonly char [] whitespaceChars = new char [] {' ', '\r', '\n', '\t'};
 
                public SignedXml () 
@@ -680,18 +683,21 @@ namespace System.Security.Cryptography.Xml {
                        if (pkEnumerator == null) {
                                pkEnumerator = m_signature.KeyInfo.GetEnumerator ();
                        }
-
-                       if (pkEnumerator.MoveNext ()) {
-                               AsymmetricAlgorithm key = null;
-                               KeyInfoClause kic = (KeyInfoClause) pkEnumerator.Current;
-
+                       
 #if NET_2_0
-                               if (kic is KeyInfoX509Data) {
-                                       foreach (X509Certificate cert in ((KeyInfoX509Data) kic).Certificates)
-                                               // FIXME: this GetRawCertData() should not be required, but it somehow causes crash.
-                                               return new X509Certificate2 (cert.GetRawCertData ()).PublicKey.Key;
+                       if (_x509Enumerator != null) {
+                               if (_x509Enumerator.MoveNext ()) {
+                                       X509Certificate cert = (X509Certificate) _x509Enumerator.Current;
+                                       return new X509Certificate2 (cert.GetRawCertData ()).PublicKey.Key;
+                               } else {
+                                       _x509Enumerator = null;
                                }
+                       }
 #endif
+                       while (pkEnumerator.MoveNext ()) {
+                               AsymmetricAlgorithm key = null;
+                               KeyInfoClause kic = (KeyInfoClause) pkEnumerator.Current;
+
                                if (kic is DSAKeyValue)
                                        key = DSA.Create ();
                                else if (kic is RSAKeyValue) 
@@ -701,6 +707,16 @@ namespace System.Security.Cryptography.Xml {
                                        key.FromXmlString (kic.GetXml ().InnerXml);
                                        return key;
                                }
+
+#if NET_2_0
+                               if (kic is KeyInfoX509Data) {
+                                       _x509Enumerator = ((KeyInfoX509Data) kic).Certificates.GetEnumerator ();
+                                       if (_x509Enumerator.MoveNext ()) {
+                                               X509Certificate cert = (X509Certificate) _x509Enumerator.Current;
+                                               return new X509Certificate2 (cert.GetRawCertData ()).PublicKey.Key;
+                                       }
+                               }
+#endif
                        }
                        return null;
                }