Bug 44566 - HttpClient gives RemoteCertificateNameMismatch when connecting to non-443 port though host name matches CN of SSL certificate
Summary: HttpClient gives RemoteCertificateNameMismatch when connecting to non-443 por...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2016-09-21 12:53 UTC by juha.joensuu
Modified: 2017-07-06 19:47 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample Android app (67.01 KB, application/zip)
2016-09-21 12:53 UTC, juha.joensuu
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description juha.joensuu 2016-09-21 12:53:07 UTC
Created attachment 17638 [details]
Sample Android app

Connecting to an https site with HttpClient gives an exception "System.Net.WebException: Error: TrustFailure (The authentication or decryption has failed.)" when the web service is running on some other port than 443, even if certificate CN matches the host and should be valid.

It should not matter what port the service is running on. 

ServerCertificateValidationCallback also gets called with policyErrors == SslPolicyError.RemoteCertificateNameMismatch.

I have tried running the same service on two different ports with the same SSL certificate. 443 works without problems, but any other port gives the error mentioned above. Our PCL code works fine when used by a Windows Phone app.

How to reproduce:
Run the attached Android app

Expected results:
App makes a request and starts without errors

Actual results:
Request gives an exception

This can of course be tested with any service that has a valid certificate, and uses some other port than 443.

# Test environment (full version information)

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Professional

Windows Phone SDK 8.0 - ENU   00322-40000-00000-AA827
Windows Phone SDK 8.0 - ENU

Visual Basic 2015   00322-40000-00000-AA827
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA827
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA827
Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package   7.6.00907.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1   14.1.20512.0
ASP.NET and Web Tools 2015.1

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.8.1   14.0.11123.0
Azure App Service Tools v2.8.1

Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.

Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

Microsoft .NET Core Tools (Preview 1)   14.1.20512.0
Microsoft .NET Core Tools (Preview 1)

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools

TypeScript   1.8.36.0
TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   14.0.25420.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   4.2.0.680 (c4382f5)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.0.0.18 (0e59c36)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.0.0.6 (6c3fee4)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 John Miller [MSFT] 2017-07-06 19:47:04 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.

Microsoft Visual Studio Enterprise 2017 
Version 15.2 (26430.12) Release
VisualStudio.15.Release/15.2.0+26430.12
Microsoft .NET Framework
Version 4.7.02046

Xamarin   4.5.0.476 (1be4f0c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.3.1.2 (9dbc4c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.10.0.35 (4cffddf)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.