// System.Net.EndPointListener
//
// Author:
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
+// Gonzalo Paniagua Javier (gonzalo.mono@gmail.com)
//
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+// Copyright (c) 2012 Xamarin, Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0 && SECURITY_DEP
+#if SECURITY_DEP
+
+#if MONOTOUCH || MONODROID
+using Mono.Security.Authenticode;
+#else
+extern alias MonoSecurity;
+using MonoSecurity::Mono.Security.Authenticode;
+#endif
using System.IO;
using System.Net.Sockets;
using System.Collections;
+using System.Collections.Generic;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
-using Mono.Security.Authenticode;
namespace System.Net {
sealed class EndPointListener
X509Certificate2 cert;
AsymmetricAlgorithm key;
bool secure;
- Hashtable unregistered;
+ Dictionary<HttpConnection, HttpConnection> unregistered;
public EndPointListener (IPAddress addr, int port, bool secure)
{
args.Completed += OnAccept;
sock.AcceptAsync (args);
prefixes = new Hashtable ();
- unregistered = new Hashtable ();
+ unregistered = new Dictionary<HttpConnection, HttpConnection> ();
}
void LoadCertificateAndKey (IPAddress addr, int port)
string path = Path.Combine (dirname, ".mono");
path = Path.Combine (path, "httplistener");
string cert_file = Path.Combine (path, String.Format ("{0}.cer", port));
+ if (!File.Exists (cert_file))
+ return;
string pvk_file = Path.Combine (path, String.Format ("{0}.pvk", port));
+ if (!File.Exists (pvk_file))
+ return;
cert = new X509Certificate2 (cert_file);
key = PrivateKey.CreateFromFile (pvk_file).RSA;
} catch {
string host = uri.Host;
int port = uri.Port;
- string path = HttpUtility.UrlDecode (uri.AbsolutePath);
+ string path = WebUtility.UrlDecode (uri.AbsolutePath);
string path_slash = path [path.Length - 1] == '/' ? path : path + "/";
HttpListener best_match = null;
{
sock.Close ();
lock (unregistered) {
- foreach (HttpConnection c in unregistered.Keys)
+ //
+ // Clone the list because RemoveConnection can be called from Close
+ //
+ var connections = new List<HttpConnection> (unregistered.Keys);
+
+ foreach (HttpConnection c in connections)
c.Close (true);
unregistered.Clear ();
}