Author: spouliot
Date: 2005-04-07 09:37:42 -0400 (Thu, 07 Apr 2005)
New Revision: 42640
Added:
trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
Modified:
trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog
trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile
Log:
2005-04-07 Sebastien Pouliot <[EMAIL PROTECTED]>
* tlsmulti.cs: New. Async GET tests using HttpWebRequest.
* Makefile: Build tlsmulti tool.
Modified: trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog 2005-04-07
13:31:52 UTC (rev 42639)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog 2005-04-07
13:37:42 UTC (rev 42640)
@@ -1,3 +1,8 @@
+2005-04-07 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * tlsmulti.cs: New. Async GET tests using HttpWebRequest.
+ * Makefile: Build tlsmulti tool.
+
2004-02-25 Sebastien Pouliot <[EMAIL PROTECTED]>
* tlstest.cs: Updated to support Basic and Digest authentication. Also
Modified: trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile 2005-04-07
13:31:52 UTC (rev 42639)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile 2005-04-07
13:37:42 UTC (rev 42640)
@@ -15,13 +15,16 @@
clean-local:
rm -f *.exe *.pdb
-sources = tlstest.cs
+sources = tlstest.cs tlsmulti.cs
DISTFILES = $(sources)
dist-local: dist-default
-all: tlstest.exe
+all: tlstest.exe tlsmulti.exe
-tlstest.exe: $(sources)
- $(CSCOMPILE) /target:exe /out:$@ $(sources)
+tlstest.exe: tlstest.cs
+ $(CSCOMPILE) /target:exe /out:$@ $^
+
+tlsmulti.exe: tlsmulti.cs
+ $(CSCOMPILE) /target:exe /out:$@ $^
Added: trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
2005-04-07 13:31:52 UTC (rev 42639)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
2005-04-07 13:37:42 UTC (rev 42640)
@@ -0,0 +1,106 @@
+//
+// tlsmulti.cs: Multi-sessions TLS/SSL Test Program
+// based on tlstest.cs
+//
+// Author:
+// Sebastien Pouliot <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2004-2005 Novell (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading;
+
+using Mono.Security.Protocol.Tls;
+
+public class State {
+
+ static ArrayList handleList = new ArrayList ();
+
+ private int id;
+ private HttpWebRequest request;
+ private ManualResetEvent handle;
+
+ public State (int id, HttpWebRequest req)
+ {
+ this.id = id;
+ request = req;
+ handle = new ManualResetEvent (false);
+ handleList.Add (handle);
+ }
+
+ public int Id {
+ get { return id; }
+ }
+
+ public HttpWebRequest Request {
+ get { return request; }
+ }
+
+ public void Complete ()
+ {
+ handle.Set ();
+ }
+
+ static public void WaitAll ()
+ {
+ if (handleList.Count > 0) {
+ WaitHandle[] handles = (WaitHandle[])
handleList.ToArray (typeof (WaitHandle));
+ WaitHandle.WaitAll (handles);
+ handleList.Clear ();
+ }
+ }
+}
+
+public class MultiTest {
+
+ public static void Main (string[] args)
+ {
+ if (args.Length > 64) {
+ Console.WriteLine ("WaitHandle has a limit of 64
handles so you cannot process {0} URLs.", args.Length);
+ return;
+ }
+
+ ServicePointManager.CertificatePolicy = new
TestCertificatePolicy ();
+
+ int id = 1;
+ foreach (string url in args) {
+ Console.WriteLine ("GET #{0} at {1}", id, url);
+ HttpWebRequest wreq = (HttpWebRequest)
WebRequest.Create (url);
+ State s = new State (id++, wreq);
+ wreq.BeginGetResponse (new AsyncCallback
(ResponseCallback), s);
+ }
+
+ State.WaitAll ();
+ }
+
+ private static void ResponseCallback (IAsyncResult result)
+ {
+ State state = ((State) result.AsyncState);
+ HttpWebResponse response = (HttpWebResponse)
state.Request.EndGetResponse (result);
+
+ Stream stream = response.GetResponseStream ();
+ StreamReader sr = new StreamReader (stream, Encoding.UTF8);
+ sr.ReadToEnd ();
+
+ Console.WriteLine ("END #{0}", state.Id);
+ state.Complete ();
+ }
+
+ public class TestCertificatePolicy : ICertificatePolicy {
+
+ public bool CheckValidationResult (ServicePoint sp,
X509Certificate certificate, WebRequest request, int 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