简体   繁体   English

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

[英]Xamarin PCL using other port than 443 communicating with REST Api

I have a Xamarin PCL client talking to a WebApi backend using SSL with an Letsnecrypt certificate. 我有一个Xamarin PCL客户端使用带有Letsnecrypt证书的SSL与WebApi后端通信。 Everything works fine when using port number 443 (no :443 in the URL, just https). 使用端口号443时,一切正常(URL中没有:443,只有https)。

I cannot use this port for various reasons, so I switched to 8082 instead. 我出于各种原因无法使用此端口,因此我切换到8082。 Now I get the following error in the client: 现在我在客户端中收到以下错误:

Error: SecureChannelFailure (The authentication or decryption has failed.) 错误:SecureChannelFailure(身份验证或解密失败。)

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 在/Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/Mono.Security/Mono.Security中的Mono.Security.Protocol.Tls.SslStreamBase.EndRead(System.IAsyncResult asyncResult)[0x00051] .Protocol.Tls / SslStreamBase.cs:883位于/ Users / builder / data / lanes / 3511 / 77cb8568 / source / mono / mcs中的Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsClient(System.IAsyncResult asyncResult)[0x00011] /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]在Mono的/Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/System/Mono.Net.Security/LegacySslStream.cs:445。 / Users / builder / data / lanes / 3511 / 77cb8568 / source / mono中的Net.Security.MonoTlsStream.CreateStream(System.Byte [] buffer)[0x0001e] /mcs/class/System/Mono.Net.Security/MonoTlsStream.cs:99 /mcs/class/System/Mono.Net.Security/MonoTlsStream.cs:99

When I use the browser in the client and open the URL everything works fine. 当我在客户端使用浏览器并打开URL时,一切正常。 The certificate is approved. 证书已获批准。 Have tried https://www.digicert.com/help/ to check certificate and everything works out fine. 已经尝试过https://www.digicert.com/help/来检查证书,一切正常。

I am using the ModernHttpClient: 我正在使用ModernHttpClient:

client = new HttpClient(new NativeMessageHandler());

What am I doing wrong? 我究竟做错了什么?

I believe this may be a Mono bug [1] which has been fixed but the fix is only released to our Alpha channel. 我相信这可能是一个Mono bug [1]已修复,但修复程序只发布到我们的Alpha通道。 Can you try updating to the Alpha channel [2] and see if the issue is resolved? 您可以尝试更新到Alpha通道[2]并查看问题是否已解决?

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

[2] Switching update channels: [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. 在Xamarin Studio中,您可以使用Xamarin Studio-> Check for Updates ...菜单切换更新频道,在Update Channel旁边的下拉列表中选择Stable,Beta或Alpha,然后单击Switch Channel按钮。

In Visual Studio, navigate to menu Tools->Options and scroll down to expand the Xamarin section and select "Other". 在Visual Studio中,导航到菜单工具 - >选项,然后向下滚动以展开Xamarin部分并选择“其他”。 Choose Stable, Beta, or Alpha from the drop down menu and click Check Now. 从下拉菜单中选择Stable,Beta或Alpha,然后单击立即检查。 If updates to that channel are available, you will get a dialog similar to the above for Xamarin Studio. 如果对该频道的更新可用,您将获得类似于上述Xamarin Studio的对话框。 Proceed as above. 按上述步骤进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM