Xamarin PCL 使用 443 以外的其他端口与 REST Api 通信

Xamarin PCL using other port than 443 communicating with REST Api

我有一个 Xamarin PCL 客户端使用带有 Letsnecrypt 证书的 SSL 与 WebApi 后端通信。使用端口号 443 时一切正常(URL 中没有 :443,只是 https)。

由于各种原因我不能使用这个端口,所以我改用了8082。现在我在客户端收到以下错误:

Error: SecureChannelFailure (The authentication or decryption has failed.)

at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (System.IAsyncResult asyncResult) [0x00051] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:883 at Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsClient (System.IAsyncResult asyncResult) [0x00011] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/System/Mono.Net.Security/LegacySslStream.cs:475 at Mono.Net.Security.Private.LegacySslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x00000] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/System/Mono.Net.Security/LegacySslStream.cs:445 at Mono.Net.Security.MonoTlsStream.CreateStream (System.Byte[] buffer) [0x0001e] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/System/Mono.Net.Security/MonoTlsStream.cs:99

当我在客户端使用浏览器并打开 URL 时一切正常。证书被批准。已尝试 https://www.digicert.com/help/ 检查证书,一切正常。

我正在使用 ModernHttpClient:

client = new HttpClient(new NativeMessageHandler());

我做错了什么?

我认为这可能是一个 Mono 错误 [1],该错误已得到修复,但该修复仅发布到我们的 Alpha 频道。您能否尝试更新到 Alpha 频道 [2] 并查看问题是否已解决?

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=46549

[2] 切换更新频道:

In Xamarin Studio, you can switch the update channel with the Xamarin Studio->Check for Updates… menu, choosing Stable, Beta, or Alpha in the drop down next to Update Channel and then clicking the Switch Channel button.

In Visual Studio, navigate to menu Tools->Options and scroll down to expand the Xamarin section and select "Other". Choose Stable, Beta, or Alpha from the drop down menu and click Check Now. If updates to that channel are available, you will get a dialog similar to the above for Xamarin Studio. Proceed as above.