简体   繁体   中英

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. Everything works fine when using port number 443 (no :443 in the URL, just https).

I cannot use this port for various reasons, so I switched to 8082 instead. Now I get the following error in the client:

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

When I use the browser in the client and open the URL everything works fine. The certificate is approved. Have tried https://www.digicert.com/help/ to check certificate and everything works out fine.

I am using the 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. Can you try updating to the Alpha channel [2] and see if the issue is resolved?

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

[2] Switching update channels:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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