Skip to content

Commit

Permalink
TorHttpClient: SslStream is supposed to support SNI since .NET Core 2.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiminuo authored and molnard committed Oct 22, 2020
1 parent 4fe44f8 commit fe71858
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions WalletWasabi/TorSocks5/TorHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, Can

// https://tools.ietf.org/html/rfc7230#section-2.7.1
// A sender MUST NOT generate an "http" URI with an empty host identifier.
var host = Guard.NotNullOrEmptyOrWhitespace($"{nameof(request)}.{nameof(request.RequestUri)}.{nameof(request.RequestUri.DnsSafeHost)}", request.RequestUri.DnsSafeHost, trim: true);
string host = Guard.NotNullOrEmptyOrWhitespace($"{nameof(request)}.{nameof(request.RequestUri)}.{nameof(request.RequestUri.DnsSafeHost)}", request.RequestUri.DnsSafeHost, trim: true);

// https://tools.ietf.org/html/rfc7230#section-2.6
// Intermediaries that process HTTP messages (i.e., all intermediaries
Expand All @@ -197,25 +197,7 @@ public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, Can
Stream stream = TorSocks5Client.TcpClient.GetStream();
if (request.RequestUri.Scheme == "https")
{
SslStream sslStream;
// On Linux and OSX ignore certificate, because of a .NET Core bug
// This is a security vulnerability, has to be fixed as soon as the bug get fixed
// Details:
// https://github.com/dotnet/corefx/issues/21761
// https://github.com/nopara73/DotNetTor/issues/4
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
sslStream = new SslStream(
stream,
leaveInnerStreamOpen: true);
}
else
{
sslStream = new SslStream(
stream,
leaveInnerStreamOpen: true,
userCertificateValidationCallback: (a, b, c, d) => true);
}
SslStream sslStream = new SslStream(stream, leaveInnerStreamOpen: true);

await sslStream
.AuthenticateAsClientAsync(
Expand Down

0 comments on commit fe71858

Please sign in to comment.