Author: spouliot
Date: 2005-04-15 08:21:09 -0400 (Fri, 15 Apr 2005)
New Revision: 43039
Added:
trunk/mcs/class/Mono.Security/Test/tools/tlstest/README
trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlssave.cs
Modified:
trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog
trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile
trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsasync.cs
trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
Log:
2005-04-15 Sebastien Pouliot <[EMAIL PROTECTED]>
* README: informations about the different tools;
* tlssave.cs: New. Async HttpWebRequest and streams using HTTP or
HTTPS GET. Saves the downloaded page to disk (1, 2, ... X).
* Makefile: Updated for tlssave.
Modified: trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog 2005-04-15
12:12:45 UTC (rev 43038)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/ChangeLog 2005-04-15
12:21:09 UTC (rev 43039)
@@ -1,3 +1,10 @@
+2005-04-15 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * README: informations about the different tools;
+ * tlssave.cs: New. Async HttpWebRequest and streams using HTTP or
+ HTTPS GET. Saves the downloaded page to disk (1, 2, ... X).
+ * Makefile: Updated for tlssave.
+
2005-04-09 Sebastien Pouliot <[EMAIL PROTECTED]>
* tlsasync.cs: New. Async HttpWebRequest and streams using HTTP or
Modified: trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile 2005-04-15
12:12:45 UTC (rev 43038)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/Makefile 2005-04-15
12:21:09 UTC (rev 43039)
@@ -15,13 +15,13 @@
clean-local:
rm -f *.exe *.pdb
-sources = tlstest.cs tlsmulti.cs tlsasync.cs
+sources = tlstest.cs tlsmulti.cs tlsasync.cs tlssave.cs
DISTFILES = $(sources)
dist-local: dist-default
-all: tlstest.exe tlsmulti.exe tlsasync.exe
+all: tlstest.exe tlsmulti.exe tlsasync.exe tlssave.exe
tlstest.exe: tlstest.cs
$(CSCOMPILE) /target:exe /out:$@ $^
@@ -31,3 +31,6 @@
tlsasync.exe: tlsasync.cs
$(CSCOMPILE) /target:exe /out:$@ $^
+
+tlssave.exe: tlssave.cs
+ $(CSCOMPILE) /target:exe /out:$@ $^
Added: trunk/mcs/class/Mono.Security/Test/tools/tlstest/README
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/README 2005-04-15
12:12:45 UTC (rev 43038)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/README 2005-04-15
12:21:09 UTC (rev 43039)
@@ -0,0 +1,30 @@
+The tlstest directory contains several test tools. They were made to test
+the SSL/TLS implementation but most of them are also good test for regular
+HTTP (when used with HttpWebRequest).
+
+
+tlstest
+ * works with HttpWebRequest (--web) or SslClientStream (--ssl | --tls)
+ * work synchronously;
+
+tlsmulti
+ * only works with HttpWebRequest (http or https)
+ * work asynchronously with Begin|EndGetResponse;
+ * can download up to 64 URLs simulteanously;
+
+tlsasync
+ * only works with HttpWebRequest (http or https)
+ * work asynchronously with Begin|EndGetResponse and [Begin|End]
+ GetResponseStream;
+ * can download up to 64 URLs simulteanously;
+
+tlssave
+ * only works with HttpWebRequest (http or https)
+ * work asynchronously with Begin|EndGetResponse and [Begin|End]
+ GetResponseStream;
+ * saves every downloaded URL into a file (1, 2, ...);
+ * used to download and compare (md5sum) very large files;
+
+
+Note: With Mono the HttpWebRequest will call the SslClientStream for HTTPS.
+However under the MS runtime SslClientStream won't be called.
Modified: trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsasync.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsasync.cs
2005-04-15 12:12:45 UTC (rev 43038)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsasync.cs
2005-04-15 12:21:09 UTC (rev 43039)
@@ -91,7 +91,7 @@
public static void Main (string[] args)
{
if (args.Length == 0) {
- Console.WriteLine ("usage: mono testmulti.exe url1 [url
...]");
+ Console.WriteLine ("usage: mono tlsaync.exe url1 [url
...]");
return;
} else if (args.Length > 64) {
Console.WriteLine ("WaitHandle has a limit of 64
handles so you cannot process {0} URLs.", args.Length);
Modified: trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
2005-04-15 12:12:45 UTC (rev 43038)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlsmulti.cs
2005-04-15 12:21:09 UTC (rev 43039)
@@ -67,7 +67,7 @@
public static void Main (string[] args)
{
if (args.Length == 0) {
- Console.WriteLine ("usage: mono testmulti.exe url1 [url
...]");
+ Console.WriteLine ("usage: mono tlsmulti.exe url1 [url
...]");
return;
} else if (args.Length > 64) {
Console.WriteLine ("WaitHandle has a limit of 64
handles so you cannot process {0} URLs.", args.Length);
Added: trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlssave.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlssave.cs 2005-04-15
12:12:45 UTC (rev 43038)
+++ trunk/mcs/class/Mono.Security/Test/tools/tlstest/tlssave.cs 2005-04-15
12:21:09 UTC (rev 43039)
@@ -0,0 +1,145 @@
+//
+// tlssave.cs: Multi-sessions TLS/SSL Test Program which saves the URL to disk
+// based on tlstest.cs, tlsmulti.cs and tlsasync.cs
+//
+// Author:
+// Sebastien Pouliot <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2004-2005 Novell (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+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;
+ private Stream stream;
+ private byte[] buffer;
+ private FileStream file;
+
+ 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 Stream Stream {
+ get { return stream; }
+ set { stream = value; }
+ }
+
+ public byte[] Buffer {
+ get {
+ if (buffer == null)
+ buffer = new byte [256]; // really small on
purpose
+ return buffer;
+ }
+ }
+
+ public Stream File {
+ get {
+ if (file == null)
+ file = new FileStream (id.ToString (),
FileMode.Create);
+ return file;
+ }
+ }
+
+ public void Complete ()
+ {
+ if (file != null)
+ file.Close ();
+ handle.Set ();
+ }
+
+ static public void WaitAll ()
+ {
+ if (handleList.Count > 0) {
+ WaitHandle[] handles = (WaitHandle[])
handleList.ToArray (typeof (WaitHandle));
+ WaitHandle.WaitAll (handles);
+ handleList.Clear ();
+ }
+ }
+}
+
+public class SaveTest {
+
+ public static void Main (string[] args)
+ {
+ if (args.Length == 0) {
+ Console.WriteLine ("usage: mono tlssave.exe url1 [url
...]");
+ return;
+ } else 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);
+ state.Stream = response.GetResponseStream ();
+ state.Stream.BeginRead (state.Buffer, 0, state.Buffer.Length,
new AsyncCallback (StreamCallBack), state);
+ }
+
+ private static void StreamCallBack (IAsyncResult result)
+ {
+ State state = ((State) result.AsyncState);
+ int length = state.Stream.EndRead (result);
+ if (length > 0) {
+ state.File.Write (state.Buffer, 0, length);
+ state.Stream.BeginRead (state.Buffer, 0,
state.Buffer.Length, new AsyncCallback (StreamCallBack), state);
+ } else {
+ state.Stream.Close ();
+ 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