Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by tiesselune · Jul 24, 2013 at 10:17 AM · c#webplayersocketstreamtcpclient

TCPClient and SslStreams in WebPlayer (C#)

Hello all!

I am writing a module that communicates with an SSL server via a TCPClient and SSLStream in C#.

The problem is: it works perfectly in the ViewPort with webplayer presets or in standalone applications, but it does not in the actual Unity WebPlayer.

Although I have a working socket policy server set up and the SSL handshake seems to complete, when writing on the SSLStream, the server receives 0 bytes and the connection closes.

Here is the client code:

     TcpClient client = new TcpClient("xxx.xx.xxx.x",xxx);
     Debug.Log("Client connected.");
     NetworkStream stream = client.GetStream();
     SslStream sslStream = new SslStream(
         stream, 
         true, 
         new RemoteCertificateValidationCallback (ValidateServerCertificate) 
         );
     try 
     {
             sslStream.AuthenticateAsClient("CertificateSigningName",null,System.Security.Authentication.SslProtocols.Ssl3,false);
             Debug.Log ("End of handshake");     
             sslStream.Write(System.BitConverter.GetBytes(someInt),0,4);
     } 

EDIT: I've been able to see into the webplayer logs that gives me the following output:

 SocketPolicyClient1: Incoming GetPolicyStreamForIP
 SocketPolicyClient1: About to BeginConnect to xxx.xxx.xxx.xxx:843
 SocketPolicyClient1: About to WaitOne
 SocketPolicyClient1: Socket connected
 Client connected. // This is a log line that I generated, see previous code.
  
 (Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/ExportGenerated/WebPlayer/UnityEngineDebug.cpp Line: 54)
 
 Exception: The authentication or decryption has failed.   at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  
 (Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/ExportGenerated/WebPlayer/UnityEngineDebug.cpp Line: 54)
 
 Inner exception: Cannot cast from source type to destination type.

This does not happen in the view port. In the Mono Compatibility list, SslStream is supposed to be supported in the web player. Any Idea?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image diekeure · Mar 06, 2014 at 03:35 PM 0
Share

I have the exact same issue, hope you get an answer.

avatar image tiesselune · Mar 07, 2014 at 03:11 PM 0
Share

I have found no answer whatsoever. So I changed my protocol because I had control over the server side. For the web player, maybe one could use a javascript plugin in the webpage to use websockets and WSS protocol on a HTTPS web page?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How do you debug a System.IO exception Unity won't load in WebPlayer? 2 Answers

Server TCP/IP socket problem after received one message 0 Answers

Trouble Connecting Unity with Labview 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges