Skip to content

Commit 7260940

Browse files
RoSchmiSecjosesimoes
authored andcommitted
Add SslProtocol property to allow selecting it (#24)
1 parent 2aa1421 commit 7260940

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

source/nanoFramework.System.Net.Http-client/System.Net.Http-client.nfproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
</ItemGroup>
110110
<ItemGroup>
111111
<None Include="..\key.snk" />
112-
<None Include="\nanoFramework.System.Net.Http\packages.config" >
112+
<None Include="\nanoFramework.System.Net.Http\packages.config">
113113
<Link>packages.config</Link>
114114
</None>
115115
</ItemGroup>

source/nanoFramework.System.Net.Http-server/System.Net.Http-server.nfproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
</ItemGroup>
105105
<ItemGroup>
106106
<None Include="..\key.snk" />
107-
<None Include="\nanoFramework.System.Net.Http\packages.config" >
107+
<None Include="\nanoFramework.System.Net.Http\packages.config">
108108
<Link>packages.config</Link>
109109
</None>
110110
</ItemGroup>

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ public class HttpListener
8989
/// </summary>
9090
private Thread m_thAccept;
9191

92+
/// <summary>
93+
/// SslProtocol which shall be used.
94+
/// </summary>
95+
private SslProtocols m_sslProtocols = SslProtocols.None;
96+
97+
/// <summary>
98+
/// Gets or sets the <see cref="SslProtocol"/> which shall be used.
99+
/// </summary>
100+
public SslProtocols SslProtocols
101+
{
102+
get { return m_sslProtocols; }
103+
set { m_sslProtocols = value; }
104+
}
105+
92106
/// <summary>
93107
/// Creates an HTTP or HTTPS listener on the standard ports.
94108
/// </summary>
@@ -395,7 +409,7 @@ private void AcceptThreadFunc()
395409
// Once connection estiblished need to create secure stream and authenticate server.
396410
netStream = new SslStream(clientSock);
397411

398-
SslProtocols[] sslProtocols = new SslProtocols[] { SslProtocols.Default };
412+
SslProtocols[] sslProtocols = new SslProtocols[] { m_sslProtocols };
399413

400414
// Throws exception if fails.
401415
((SslStream)netStream).AuthenticateAsServer(m_httpsCert, sslProtocols);

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ protected override void Dispose(bool disposing)
205205
/// </summary>
206206
private IWebProxy m_proxy;
207207

208+
/// <summary>
209+
/// Select <see cref="SslProtocol"/> to be used for requests. The default is <see cref="SslProtocol.None"/> to force setting it.
210+
/// </summary>
211+
private SslProtocols m_sslProtocols = SslProtocols.None;
212+
208213
/// <summary>
209214
/// Whether to use persistent connections.
210215
/// </summary>
@@ -356,6 +361,16 @@ public X509Certificate HttpsAuthentCert
356361
set { m_caCert = value; }
357362
}
358363

364+
365+
/// <summary>
366+
/// Gets or sets the <see cref="SslProtocol"/> which shall be used for requests.
367+
/// </summary>
368+
public SslProtocols SslProtocols
369+
{
370+
get { return m_sslProtocols; }
371+
set { m_sslProtocols = value; }
372+
}
373+
359374
/// <summary>
360375
/// Gets or sets a timeout in milliseconds when writing to or reading
361376
/// from a stream.
@@ -1440,7 +1455,7 @@ private InputNetworkStreamWrapper EstablishConnection(Uri proxyServer, Uri targe
14401455
SslStream sslStream = new SslStream(retStream.m_Socket);
14411456

14421457
// Throws exception is fails.
1443-
sslStream.AuthenticateAsClient(m_originalUrl.Host, null, m_caCert, SslProtocols.Default);
1458+
sslStream.AuthenticateAsClient(m_originalUrl.Host, null, m_caCert, m_sslProtocols);
14441459

14451460
// Changes the stream to SSL stream.
14461461
retStream.m_Stream = sslStream;

0 commit comments

Comments
 (0)