Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to accept self signed certificateSSL certificate on Android Platform #61

Open
Raj123456788 opened this issue Oct 14, 2016 · 14 comments

Comments

@Raj123456788
Copy link

Hi,
I downloaded your examples and running lates stable version of websocket4net. Is there a way I can achieve ServerCertificateValidationCallback to return true able to connect to server accepting wss:// connection. Will it work with TLS 1.0 since Xamarin is running few version behind to mono 4.6 which has the fix for TLS 1.2

I would appreciate if you can give a detail answer.

Things tried: #46 : Allow certificate does not help.
#40

Thanks!

@Raj123456788
Copy link
Author

Just updated VS 2015 release notes say Mono 4.6.1 but still throwing java.ssl.exception. Can anyone advise? It is pretty critical.

@kerryjiang
Copy link
Owner

What's the error did you get? The exception's message should help.

@Raj123456788
Copy link
Author

Raj123456788 commented Oct 15, 2016

I am getting: "Error while sending TLS Alert (Fatal:InternalError): System.IO.IOException: The authentication or de…" only for
for wss:// connection but for ws:// it works. Let me know!

@Raj123456788
Copy link
Author

Raj123456788 commented Oct 15, 2016

On using: WebSocket(string uri, string subProtocol = "", List<KeyValuePair<string, string>> cookies = null, List<KeyValuePair<string, string>> customHeaderItems = null, string userAgent = "", string origin = "", WebSocketVersion version = WebSocketVersion.None, EndPoint httpConnectProxy = null, SslProtocols sslProtocols = SslProtocols.None, int receiveBufferSize = 0)

used TLS1, 1.1 & 1.2 none of them worked
I get this error
"Error while sending TLS Alert (Fatal:InternalError): System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.\n at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x0003a] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:430 \n at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:256 \n at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:418 \n --- End of inner exception stack trace ---\n at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) [0x00035] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:396 \n at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:101 "

@Raj123456788
Copy link
Author

Any Suggestions?

@kerryjiang
Copy link
Owner

Could you try WebSocket4Net 0.15.0-beta6 instead?

@Raj123456788
Copy link
Author

ok. I will try it and let you know. How did you resolve the error since the bug was in mono.

@kerryjiang
Copy link
Owner

There are two properties of websocket's Security option you may need:

   /// <summary>
    /// Whether allow untrusted certificate
    /// </summary>
    public bool AllowUnstrustedCertificate { get; set; }

    /// <summary>
    /// Whether allow the certificate whose name doesn't match current remote endpoint's host name
    /// </summary>
    public bool AllowNameMismatchCertificate { get; set; }

@Raj123456788
Copy link
Author

Raj123456788 commented Dec 13, 2016

Getting This error:
Install-Package : Could not install package 'SuperSocket.ClientEngine.Core 0.8.0.6'. You are trying to install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For
more information, contact the package author.
At line:1 char:1

  • Install-Package WebSocket4Net -Pre
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    

Can you help me with this?

@kerryjiang
Copy link
Owner

I am not sure if PCL project can reference one .net core assembly.

@gcadmes
Copy link

gcadmes commented Dec 22, 2016

Hi Kerry,

I work with Raj at the same company and wanted to help flush-out the SSL issue we're having.
By the way, I've made it past Raj's previous message, regarding the compiling errors he had with netstandard and profile stuff.

I installed the latest version (0.15.0-beta6) and I don't see the two API's you mentioned above:
AllowUnstrustedCertificate
AllowNameMismatchCertificate

Are those properties supposed to be in the 0.15.0-beta6?

Also, running the 0.15.0-beta6, trying to connect via wss, I received the following exception:

"Error while sending TLS Alert (Fatal:InternalError): System.IO.IOException: The authentication or de…

Can you help us with this? If this is a bug, could it be with the SuperSocket.ClientEngine.SslStreamTcpSession?

Here is the stack trace and exception:

[0:] The authentication or decryption has failed.
[0:] Error while sending TLS Alert (Fatal:InternalError): System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer
at System.Net.Sockets.Socket.EndReceive (System.IAsyncResult result) [0x0002d] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/System/System.Net.Sockets/Socket.cs:2031
at System.Net.Sockets.NetworkStream.EndRead (System.IAsyncResult asyncResult) [0x0005f] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:858
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x0003a] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:430
at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:256
at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:418
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) [0x00035] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:396
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:101
[0:] at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (System.IAsyncResult asyncResult) [0x00051] in /Users/builder/data/lanes/3819/96c7ba6c/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/3819/96c7ba6c/source/mono/mcs/class/System/Mono.Net.Security/LegacySslStream.cs:475
at Mono.Net.Security.Private.MonoSslStreamImpl.EndAuthenticateAsClient (System.IAsyncResult asyncResult) [0x00000] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/System/Mono.Net.Security/MonoSslStreamImpl.cs:92
at System.Net.Security.SslStream.EndAuthenticateAsClient (System.IAsyncResult asyncResult) [0x00000] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/System/System.Net.Security/SslStream.cs:164
at SuperSocket.ClientEngine.SslStreamTcpSession.OnAuthenticated (System.IAsyncResult result) [0x00028] in <44ed3ac7b32540fe81f4e64e17213df6>:0

thanks much,
Greg

@kerryjiang
Copy link
Owner

They are properties of Security.

websocket.Security.AllowUnstrustedCertificate
websocket.Security.AllowNameMismatchCertificate

@gcadmes
Copy link

gcadmes commented Dec 29, 2016

HI Kerry,

Your properties didn't help.
I'm fairly certain you're not using the latest preview of Mono 4.8, which boasts the TLS bug fix for TLS1.2.
http://www.mono-project.com/docs/about-mono/releases/4.8.0/#tls-12-support

Will you need to make changes in the SuperSocket codebase to incorporate the fix?

@kerryjiang
Copy link
Owner

Sorry, I cannot understand the problem.
It seems the exception was thrown from Mono, so it is issue of Mono?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants