#if SECURITY_DEP
-#if MONOTOUCH || MONODROID
-using Mono.Security.Authenticode;
-#else
+#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
using MonoSecurity::Mono.Security.Authenticode;
+#else
+using Mono.Security.Authenticode;
#endif
using System.IO;
namespace System.Net {
sealed class EndPointListener
{
+ HttpListener listener;
IPEndPoint endpoint;
Socket sock;
Hashtable prefixes; // Dictionary <ListenerPrefix, HttpListener>
ArrayList unhandled; // List<ListenerPrefix> unhandled; host = '*'
ArrayList all; // List<ListenerPrefix> all; host = '+'
- X509Certificate2 cert;
+ X509Certificate cert;
bool secure;
Dictionary<HttpConnection, HttpConnection> unregistered;
- public EndPointListener (IPAddress addr, int port, bool secure)
+ public EndPointListener (HttpListener listener, IPAddress addr, int port, bool secure)
{
+ this.listener = listener;
+
if (secure) {
this.secure = secure;
- LoadCertificateAndKey (addr, port);
+ cert = listener.LoadCertificateAndKey (addr, port);
}
endpoint = new IPEndPoint (addr, port);
unregistered = new Dictionary<HttpConnection, HttpConnection> ();
}
- void LoadCertificateAndKey (IPAddress addr, int port)
- {
- // Actually load the certificate
- try {
- string dirname = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
- 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);
- cert.PrivateKey = PrivateKey.CreateFromFile (pvk_file).RSA;
- } catch {
- // ignore errors
- }
+ internal HttpListener Listener {
+ get { return listener; }
}
static void OnAccept (object sender, EventArgs e)
if (accepted == null)
return;
- if (epl.secure && (epl.cert == null || !epl.cert.HasPrivateKey)) {
+ if (epl.secure && epl.cert == null) {
accepted.Close ();
return;
}