-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 X509ChainPolicy to SslOptions #71191
Comments
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsBackground and motivationWhen TLS handshake is completed SslStream does peer certificate validation. This happens always on client and it can happen on server if client cert is provided. This process can for example download additional certificates over network and there is no way how caller can impact the processing. Only after al this is done custom delegate can be called for additional checks. This is inconvenient and it can possibly lead to performance or security issues.
related to #59979, #35839, #59944, #40423 API Proposalnamespace System.Net.Security
{
public class SslServerAuthenticationOptions
{
....
+ X509ChainPolicy? ValidationPolicy;
}
public class SslClientAuthenticationOptions
{
....
+ X509ChainPolicy? ValidationPolicy;
}
} API Usageon client X509ChainPolicy policy = new X509ChainPolicy();
policy.CustomTrustMode = CustomRootTrust;
policy.TrustStore.Add(s_ourPrivateRoot);
policy.UrlRetrievalTimeout = TimeSpan.FromSeconds(3);
SslStreamClientOptions options = new SslStreamClientOptions();
options.TargetName = "myServer";
options.ValidationPolicy = policy;
var ssl = new SslStream(transportStream);
ssl.AuthenticateAsClientAsync(options, cancellationToken); on server preventing downloads: X509ChainPolicy policy = new X509ChainPolicy();
policy.DisableCertificateDownload = true;
var options = new SslServerAuthenticationOptions();
options. ValidationPolicy = policy;
var ssl = new SslStream(transportStream);
ssl.AuthenticateAsServerAsync(options, cancellationToken);
### Alternative Designs
We could add specific properties to SslOptions and use them when creating similar to `CertificateRevocationCheckMode`. The problem is duplication as well as maintenance. We may add new options to `X509ChainPolicy` and it would be immediately available to callers of SslStream. If we keep adding discrete properties we will be always behind.
### Risks
Current validation is hidden from callers and pretty simple. Fiddling with `X509ChainPolicy` is for advanced users and misconfiguring it can have security impact.
<table>
<tr>
<th align="left">Author:</th>
<td>wfurt</td>
</tr>
<tr>
<th align="left">Assignees:</th>
<td>-</td>
</tr>
<tr>
<th align="left">Labels:</th>
<td>
`api-suggestion`, `area-System.Net.Security`
</td>
</tr>
<tr>
<th align="left">Milestone:</th>
<td>-</td>
</tr>
</table>
</details> |
namespace System.Net.Security
{
public partial class SslServerAuthenticationOptions
{
public X509ChainPolicy? ValidationPolicy { get; set; }
}
public class SslClientAuthenticationOptions
{
public X509ChainPolicy? ValidationPolicy { get; set; }
}
}
namespace System.Security.Cryptography.X509ChainPolicy
{
public partial class X509ChainPolicy
{
public X509ChainPolicy Clone();
// Breaking change: This defaults to true (and gets set to false if set_VerificationTime is called)
public bool VerificationTimeIgnored { get; set; }
}
} |
It seems like maybe |
Background and motivation
When TLS handshake is completed SslStream does peer certificate validation. This happens always on client and it can happen on server if client cert is provided. This process can for example download additional certificates over network and there is no way how caller can impact the processing. Only after al this is done custom delegate can be called for additional checks. This is inconvenient and it can possibly lead to performance or security issues.
SslStream
currently createsX509ChainPolicy
behind the curtain to valid peer's certificate.The proposal is to add existing
X509ChainPolicy
toSslOptions
so callers ofSslStream
can customize the validation process. If provided, it would be used exclusively and existing properties impacting validation (like CertificateRevocationCheckMode) will be ignored.related to #59979, #35839, #59944, #40423
API Proposal
API Usage
on client
on server preventing downloads:
Alternative Designs
We could add specific properties to SslOptions and use them when creating similar to
CertificateRevocationCheckMode
. The problem is duplication as well as maintenance. We may add new options toX509ChainPolicy
and it would be immediately available to callers of SslStream. If we keep adding discrete properties we will be always behind.Risks
Current validation is hidden from callers and pretty simple. Fiddling with
X509ChainPolicy
is for advanced users and misconfiguring it can have security impact.The text was updated successfully, but these errors were encountered: