@@ -22,7 +22,7 @@ namespace System.Net
22
22
/// </remarks>
23
23
public class HttpListener
24
24
{
25
- private readonly object lockObj = new object ( ) ;
25
+ private readonly object lockObj ;
26
26
27
27
/// <summary>
28
28
/// Indicates whether the listener is waiting on an http or https
@@ -122,6 +122,8 @@ public SslProtocols SslProtocols
122
122
/// class has no arguments.</remarks>
123
123
public HttpListener ( string prefix )
124
124
{
125
+ lockObj = new object ( ) ;
126
+
125
127
InitListener ( prefix , - 1 ) ;
126
128
}
127
129
@@ -137,6 +139,8 @@ public HttpListener(string prefix)
137
139
/// class has no arguments.</remarks>
138
140
public HttpListener ( string prefix , int port )
139
141
{
142
+ lockObj = new object ( ) ;
143
+
140
144
InitListener ( prefix , port ) ;
141
145
}
142
146
@@ -405,11 +409,13 @@ private void AcceptThreadFunc()
405
409
else
406
410
{
407
411
// 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.
409
413
netStream = new SslStream ( clientSock ) ;
410
414
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 ) ;
413
419
414
420
netStream . ReadTimeout = 10000 ;
415
421
}
@@ -591,7 +597,7 @@ public void Stop()
591
597
/// </example>
592
598
public HttpListenerContext GetContext ( )
593
599
{
594
- // Protects access for simulteneous call for GetContext and Close or Stop.
600
+ // Protects access for simultaneous call for GetContext and Close or Stop.
595
601
lock ( lockObj )
596
602
{
597
603
if ( m_Closed ) throw new ObjectDisposedException ( ) ;
@@ -666,8 +672,7 @@ public int MaximumResponseHeadersLength
666
672
667
673
#pragma warning disable S2292 // Trivial properties should be auto-implemented
668
674
/// <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.
671
676
/// </summary>
672
677
public X509Certificate HttpsCert
673
678
#pragma warning restore S2292 // Trivial properties should be auto-implemented
0 commit comments