Skip to content

Commit

Permalink
Added new property for HttpRequest: SslProtocols. Updated README.md f…
Browse files Browse the repository at this point in the history
…or it.
  • Loading branch information
grandsilence committed Feb 5, 2019
1 parent 6b96b8b commit 09c657c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Leaf.xNet/~Http/HttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ public event EventHandler<DownloadProgressChangedEventArgs> DownloadProgressChan
/// <value>Значение по умолчанию — <see langword="null"/>.</value>
public ProxyClient Proxy { get; set; }


/// <summary>
/// Возвращает или задает возможные протоколы SSL.
/// По умолчанию используется: <value>SslProtocols.Tls | SslProtocols.Tls12 | SslProtocols.Tls11</value>.
/// </summary>
public SslProtocols SslProtocols { get; set; } = SslProtocols.Tls | SslProtocols.Tls12 | SslProtocols.Tls11;

/// <summary>
/// Возвращает или задает метод делегата, вызываемый при проверки сертификата SSL, используемый для проверки подлинности.
/// </summary>
Expand Down Expand Up @@ -1967,11 +1974,7 @@ private void CreateConnection(Uri address)
? new SslStream(ClientNetworkStream, false, Http.AcceptAllCertificationsCallback)
: new SslStream(ClientNetworkStream, false, SslCertificateValidatorCallback);

// SSL 2 и 3 удалены, поскольку устарели
const SslProtocols supportedProtocols = SslProtocols.Tls | SslProtocols.Tls12 | SslProtocols.Tls11;

sslStream.AuthenticateAsClient(address.Host, new X509CertificateCollection(), supportedProtocols,
false);
sslStream.AuthenticateAsClient(address.Host, new X509CertificateCollection(), SslProtocols, false);
ClientStream = sslStream;
}
catch (Exception ex)
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ HttpRequest.Cookies.EscapeValuesOnReceive = false;
HttpRequest.Cookies.UnescapeValuesOnSend = false;
```

### Select SSL Protocols (downgrade when required)
```csharp
// By Default (SSL 2 & 3 not used)
httpRequest.SslProtocols = SslProtocols.Tls | SslProtocols.Tls12 | SslProtocols.Tls11;
```

### Modern User-Agent Randomization
UserAgents were updated in January 2019.
```csharp
Expand Down

0 comments on commit 09c657c

Please sign in to comment.