Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SslProtocol property to allow selecting it #24

Merged
merged 11 commits into from
Apr 5, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
</ItemGroup>
<ItemGroup>
<None Include="..\key.snk" />
<None Include="\nanoFramework.System.Net.Http\packages.config" >
<None Include="\nanoFramework.System.Net.Http\packages.config">
<Link>packages.config</Link>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</ItemGroup>
<ItemGroup>
<None Include="..\key.snk" />
<None Include="\nanoFramework.System.Net.Http\packages.config" >
<None Include="\nanoFramework.System.Net.Http\packages.config">
<Link>packages.config</Link>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ public class HttpListener
/// </summary>
private Thread m_thAccept;

/// <summary>
/// SslProtocol which shall be used.
/// </summary>
private SslProtocols m_sslProtocols = SslProtocols.None;

/// <summary>
/// Gets or sets the <see cref="SslProtocol"/> which shall be used.
/// </summary>
public SslProtocols SslProtocols
{
get { return m_sslProtocols; }
set { m_sslProtocols = value; }
}

/// <summary>
/// Creates an HTTP or HTTPS listener on the standard ports.
/// </summary>
Expand Down Expand Up @@ -395,7 +409,7 @@ private void AcceptThreadFunc()
// Once connection estiblished need to create secure stream and authenticate server.
netStream = new SslStream(clientSock);

SslProtocols[] sslProtocols = new SslProtocols[] { SslProtocols.Default };
SslProtocols[] sslProtocols = new SslProtocols[] { m_sslProtocols };

// Throws exception if fails.
((SslStream)netStream).AuthenticateAsServer(m_httpsCert, sslProtocols);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ protected override void Dispose(bool disposing)
/// </summary>
private IWebProxy m_proxy;

/// <summary>
/// Select <see cref="SslProtocol"/> to be used for requests. The default is <see cref="SslProtocol.None"/> to force setting it.
/// </summary>
private SslProtocols m_sslProtocols = SslProtocols.None;

/// <summary>
/// Whether to use persistent connections.
/// </summary>
Expand Down Expand Up @@ -356,6 +361,16 @@ public X509Certificate HttpsAuthentCert
set { m_caCert = value; }
}


/// <summary>
/// Gets or sets the <see cref="SslProtocol"/> which shall be used for requests.
/// </summary>
public SslProtocols SslProtocols
{
get { return m_sslProtocols; }
set { m_sslProtocols = value; }
}

/// <summary>
/// Gets or sets a timeout in milliseconds when writing to or reading
/// from a stream.
Expand Down Expand Up @@ -1440,7 +1455,7 @@ private InputNetworkStreamWrapper EstablishConnection(Uri proxyServer, Uri targe
SslStream sslStream = new SslStream(retStream.m_Socket);

// Throws exception is fails.
sslStream.AuthenticateAsClient(m_originalUrl.Host, null, m_caCert, SslProtocols.Default);
sslStream.AuthenticateAsClient(m_originalUrl.Host, null, m_caCert, m_sslProtocols);

// Changes the stream to SSL stream.
retStream.m_Stream = sslStream;
Expand Down