Author: spouliot
Date: 2005-04-06 12:52:58 -0400 (Wed, 06 Apr 2005)
New Revision: 42612

Modified:
   trunk/mcs/class/Mono.Security/Test/tools/postecho/ChangeLog
   trunk/mcs/class/Mono.Security/Test/tools/postecho/postecho.cs
Log:
2005-04-06  Sebastien Pouliot  <[EMAIL PROTECTED]> 
 
        * postecho.cs: Added an ICertificatePolicy to ease testing with 
        HttpWebRequest. Fixed some strings.


Modified: trunk/mcs/class/Mono.Security/Test/tools/postecho/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/postecho/ChangeLog 2005-04-06 
15:47:17 UTC (rev 42611)
+++ trunk/mcs/class/Mono.Security/Test/tools/postecho/ChangeLog 2005-04-06 
16:52:58 UTC (rev 42612)
@@ -1,6 +1,7 @@
-2005-04-06  Sebastien Pouliot  <[EMAIL PROTECTED]>
-
-       * postecho.cs: Fix some strings.
+2005-04-06  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+ 
+       * postecho.cs: Added an ICertificatePolicy to ease testing with 
+       HttpWebRequest. Fixed some strings.
        * sendback.aspx: ASP.NET version of the server script.
        * README: updated instructions with the new script.
 

Modified: trunk/mcs/class/Mono.Security/Test/tools/postecho/postecho.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/postecho/postecho.cs       
2005-04-06 15:47:17 UTC (rev 42611)
+++ trunk/mcs/class/Mono.Security/Test/tools/postecho/postecho.cs       
2005-04-06 16:52:58 UTC (rev 42612)
@@ -27,7 +27,9 @@
        }
 
        static string PostWeb (string url, byte[] buffer)
-       {
+       {
+               ServicePointManager.CertificatePolicy = new 
TestCertificatePolicy ();
+
                string postdata = "TEST=";
                HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
                req.Method = "POST";
@@ -180,5 +182,22 @@
                // whatever the reason we do not stop the SSL connection
                return true;
        }
+
+       public class TestCertificatePolicy : ICertificatePolicy {
+
+               public bool CheckValidationResult (ServicePoint sp, 
X509Certificate certificate, WebRequest request, int error)
+               {
+                       if (error != 0) {
+                               Console.WriteLine (certificate.ToString (true));
+                               // X509Certificate.ToString(true) doesn't show 
dates :-(
+                               Console.WriteLine ("\tValid From:  {0}", 
certificate.GetEffectiveDateString ());
+                               Console.WriteLine ("\tValid Until: {0}{1}", 
certificate.GetExpirationDateString (), Environment.NewLine);
+
+                               ShowCertificateError (error);
+                       }
+                       // whatever the reason we do not stop the SSL connection
+                       return true;
+               }
+       }
 }
 

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

Reply via email to