Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b59f629

Browse files
Martin Bauligstephentoub
authored andcommitted
Mono-specific HttpListener additions. (#19490)
* Mono-specific HttpListener additions. * Wrap HttpListener.CreateSslStream() in '!MONO' conditional. * Add call to HttpListener.LoadCertificateAndKey() to HttpEndPointListener's .ctor. * Use a new partial class instead of conditionals. * Make it build.
1 parent e3f4fd5 commit b59f629

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

src/System.Net.HttpListener/src/System.Net.HttpListener.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@
329329
<Compile Include="System\Net\Managed\ListenerPrefix.cs" />
330330
<Compile Include="System\Net\Managed\HttpRequestStream.Managed.cs" />
331331
<Compile Include="System\Net\Managed\HttpListener.Managed.cs" />
332+
<Compile Include="System\Net\Managed\HttpListener.Certificates.cs" />
332333
<Compile Include="System\Net\Managed\HttpListenerContext.Managed.cs" />
333334
<Compile Include="System\Net\Managed\HttpListenerRequest.Managed.cs" />
334335
<Compile Include="System\Net\Managed\HttpListenerResponse.Managed.cs" />

src/System.Net.HttpListener/src/System/Net/Managed/HttpConnection.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ internal X509Certificate2 ClientCertificate
116116
get { return _clientCert; }
117117
}
118118

119+
internal SslStream SslStream
120+
{
121+
get { return _sslStream; }
122+
}
123+
119124
private void Init()
120125
{
121126
if (_sslStream != null)

src/System.Net.HttpListener/src/System/Net/Managed/HttpEndPointListener.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public HttpEndPointListener(HttpListener listener, IPAddress addr, int port, boo
5555
if (secure)
5656
{
5757
_secure = secure;
58-
// TODO #14691: Implement functionality to read SSL certificate.
59-
_cert = null;
58+
_cert = _listener.LoadCertificateAndKey (addr, port);
6059
}
6160

6261
_endpoint = new IPEndPoint(addr, port);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Collections;
6+
using System.Collections.Generic;
7+
using System.IO;
8+
using System.Net.Security;
9+
using System.Security.Cryptography.X509Certificates;
10+
11+
namespace System.Net
12+
{
13+
partial class HttpListener
14+
{
15+
internal SslStream CreateSslStream(Stream innerStream, bool ownsStream, RemoteCertificateValidationCallback callback)
16+
{
17+
return new SslStream(innerStream, ownsStream, callback);
18+
}
19+
20+
internal X509Certificate LoadCertificateAndKey(IPAddress addr, int port)
21+
{
22+
// TODO #14691: Implement functionality to read SSL certificate.
23+
return null;
24+
}
25+
}
26+
}

src/System.Net.HttpListener/src/System/Net/Managed/HttpListener.Managed.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ public sealed unsafe partial class HttpListener
1818
private List<ListenerAsyncResult> _asyncWaitQueue = new List<ListenerAsyncResult>();
1919
private Dictionary<HttpConnection, HttpConnection> _connections = new Dictionary<HttpConnection, HttpConnection>();
2020

21-
internal SslStream CreateSslStream(Stream innerStream, bool ownsStream, RemoteCertificateValidationCallback callback)
22-
{
23-
return new SslStream(innerStream, ownsStream, callback);
24-
}
25-
2621
public HttpListenerTimeoutManager TimeoutManager
2722
{
2823
get

0 commit comments

Comments
 (0)