Skip to content

Commit 90366e3

Browse files
authored
Improvements in SSL accept handler (#62)
***PUBLISH_RELEASE***
1 parent f3122ac commit 90366e3

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

source/nanoFramework.System.Net.Http/Http/System.Net.HttpListener.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace System.Net
2222
/// </remarks>
2323
public class HttpListener
2424
{
25-
private readonly object lockObj = new object();
25+
private readonly object lockObj;
2626

2727
/// <summary>
2828
/// Indicates whether the listener is waiting on an http or https
@@ -122,6 +122,8 @@ public SslProtocols SslProtocols
122122
/// class has no arguments.</remarks>
123123
public HttpListener(string prefix)
124124
{
125+
lockObj = new object();
126+
125127
InitListener(prefix, -1);
126128
}
127129

@@ -137,6 +139,8 @@ public HttpListener(string prefix)
137139
/// class has no arguments.</remarks>
138140
public HttpListener(string prefix, int port)
139141
{
142+
lockObj = new object();
143+
140144
InitListener(prefix, port);
141145
}
142146

@@ -405,11 +409,13 @@ private void AcceptThreadFunc()
405409
else
406410
{
407411
// This is the case of https.
408-
// Once connection estiblished need to create secure stream and authenticate server.
412+
// Once connection established need to create secure stream and authenticate server.
409413
netStream = new SslStream(clientSock);
410414

411-
// Throws exception if fails.
412-
((SslStream)netStream).AuthenticateAsServer(m_httpsCert, m_sslProtocols);
415+
// Throws exception if this fails
416+
// pass the server certificate
417+
// do not require client certificate
418+
((SslStream)netStream).AuthenticateAsServer(m_httpsCert, false, m_sslProtocols);
413419

414420
netStream.ReadTimeout = 10000;
415421
}
@@ -591,7 +597,7 @@ public void Stop()
591597
/// </example>
592598
public HttpListenerContext GetContext()
593599
{
594-
// Protects access for simulteneous call for GetContext and Close or Stop.
600+
// Protects access for simultaneous call for GetContext and Close or Stop.
595601
lock (lockObj)
596602
{
597603
if (m_Closed) throw new ObjectDisposedException();
@@ -666,8 +672,7 @@ public int MaximumResponseHeadersLength
666672

667673
#pragma warning disable S2292 // Trivial properties should be auto-implemented
668674
/// <summary>
669-
/// The certificate used if <b>HttpListener</b> implements an https
670-
/// server.
675+
/// The certificate used if <see cref="HttpListener"/> implements an https server.
671676
/// </summary>
672677
public X509Certificate HttpsCert
673678
#pragma warning restore S2292 // Trivial properties should be auto-implemented

source/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.2.1-preview.{height}",
3+
"version": "1.2.2-preview.{height}",
44
"assemblyVersion": {
55
"precision": "revision"
66
},

0 commit comments

Comments
 (0)