public void OnFailure(ICall p0, IOException p1) { // https://github.com/alexrainman/ModernHttpClient/pull/65 var host = p0?.Request()?.Url()?.Host(); // Kind of a hack, but the simplest way to find out that server cert. validation failed //if (p1.Message.StartsWith("Hostname " + p0.Request().Url().Host() + " not verified", StringComparison.Ordinal)) if (host != null && p1.Message != null && p1.Message.StartsWith("Hostname " + host + " not verified", StringComparison.Ordinal)) { // SIGABRT after UnknownHostException #229 //tcs.TrySetException(new WebException(p1.Message)); //tcs.TrySetException(new WebException(p1.LocalizedMessage, WebExceptionStatus.TrustFailure)); var ex = new System.OperationCanceledException(HostnameVerifier.PinningFailureMessage, p1); HostnameVerifier.PinningFailureMessage = null; tcs.TrySetException(ex); } //else if (p1.Message.StartsWith("Certificate pinning failure", StringComparison.Ordinal)) else if (p1.Message != null && p1.Message.StartsWith("Certificate pinning failure", StringComparison.Ordinal)) { System.Diagnostics.Debug.WriteLine(p1.Message); tcs.TrySetException(new System.OperationCanceledException(FailureMessages.PinMismatch, p1)); } else { tcs.TrySetException(p1); } }
public void OnResponse(ICall p0, Response p1) { Timber.D("Url: %s", p0.Request().Url().ToString()); var body = p1.Body() as DirectionsResponse; successAction.Invoke(body); }
public void OnFailure(ICall p0, IOException p1) { // Kind of a hack, but the simplest way to find out that server cert. validation failed if (p1.Message == string.Format("Hostname '{0}' was not verified", p0.Request().Url().Host())) { tcs.TrySetException(new WebException(p1.LocalizedMessage, WebExceptionStatus.TrustFailure)); } else { tcs.TrySetException(p1); } }
public void OnFailure(ICall call, Java.IO.IOException ioException) { // Kind of a hack, but the simplest way to find out that server cert. validation failed var host = call?.Request()?.Url()?.Uri()?.Host; if (host != null && ioException.Message == $"Hostname '{host}' was not verified") { _tcs.TrySetException(new WebException(ioException.LocalizedMessage, WebExceptionStatus.TrustFailure)); } else { _tcs.TrySetException(ioException); } }
public void OnResponse(ICall call, Response response) { System.Diagnostics.Debug.WriteLine(call.Request().Url()); if (response.Body() != null) { var directions = Android.Runtime.Extensions.JavaCast <DirectionsResponse>(response.Body()); if (directions.Routes().Count > 0) { // Extract the route DirectionsRoute route = directions.Routes()[0]; // Draw it on the map DrawRoute(route); // Start mocking the new route ResetLocationEngine(route); navigation.StartNavigation(route); mapboxMap.SetOnMapClickListener(this); tracking = true; } } }
public void OnFailure(ICall call, IOException exception) { // Kind of a hack, but the simplest way to find out that server cert. validation failed if (exception.Message == String.Format("Hostname '{0}' was not verified", call.Request().Url().Host())) { tcs.TrySetException(new WebException(exception.LocalizedMessage, WebExceptionStatus.TrustFailure)); } else if (exception is UnknownHostException) { tcs.TrySetException(new System.OperationCanceledException()); } else { tcs.TrySetException(exception); } }