Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Wrap exceptions from ManagedHandler's server validation callback
Browse files Browse the repository at this point in the history
To match other handlers' behaviors.
  • Loading branch information
stephentoub committed Sep 18, 2017
1 parent 99bffa9 commit 02e4fe5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ private async ValueTask<SslStream> EstablishSslConnection(string host, HttpReque
{
callback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
{
return _settings._serverCertificateCustomValidationCallback(request, certificate as X509Certificate2, chain, sslPolicyErrors);
try
{
return _settings._serverCertificateCustomValidationCallback(request, certificate as X509Certificate2, chain, sslPolicyErrors);
}
catch (Exception e)
{
throw new HttpRequestException(SR.net_http_ssl_connection_failed, e);
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ public async Task UseCallback_CallbackReturnsFailure_ThrowsException()
[ConditionalFact(nameof(BackendSupportsCustomCertificateHandling))]
public async Task UseCallback_CallbackThrowsException_ExceptionPropagatesAsBaseException()
{
if (ManagedHandlerTestHelpers.IsEnabled)
{
return; // TODO #21904: ManagedHandler is not properly wrapping exception.
}

if (BackendDoesNotSupportCustomCertificateHandling) // can't use [Conditional*] right now as it's evaluated at the wrong time for the managed handler
{
Console.WriteLine($"Skipping {nameof(UseCallback_CallbackThrowsException_ExceptionPropagatesAsBaseException)}()");
Expand Down

0 comments on commit 02e4fe5

Please sign in to comment.