Search Unity

Can't connect with https to a cloudfront(amazon) server - authentication/decryption failed

Discussion in 'Multiplayer' started by omrip32, Apr 13, 2016.

  1. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
    Hi All :)
    I'm using the following code to to receive a response from a secured server (Unity version 5.2.3):

    WebClient client = new WebClient(); //I'm using this and not the 'WWW" class because I'm using threading for this).

    byte[] bytes = client.DownloadData("https://SomeSecuredServer");

    But I'm getting the following error:
    "Error getting response stream (Write: The authentication or decryption has failed.): SendFailure"

    A few things I've tried:

    1. initializing the 'ServicePointManager.ServerCertificateValidationCallback' and returning 'true' always in the delegate, but I'm still getting the error..
    2. using mono mozroots tool but to no avail, it crashes every time.
    3. using the certmgr tool to add the root certificate manually, it was added, but it didn't help as well.

    It's really important to note that when disabling cloudfront (and just using a regular server that supports https) the request succeeds!!
    So, I'm guessing this is due to some security issue in my request when using cloudfront.
    I really need your help people :confused::confused:

    Thanks;)
     
    JongyeobKim likes this.
  2. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
    By the way, when using the 'WWW' class this works.. Really strange.
     
  3. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
    Well, it seems I'm answering myself but what the hell ;)
    I used wireshark to find out that after sending 'client hello' message I immediatly receive an 'handshake failure' response.
    Both of them support tls v1.0 and above, so that only leaves the cipher suites..
     
  4. omrip32

    omrip32

    Joined:
    Jan 4, 2016
    Posts:
    105
    Solved the problem!!!!!
    in AWS console , SNI only was enabled. For some reason the WebClient/WebRequest/etc.. classes do not support SNI.
     
  5. prasetion

    prasetion

    Joined:
    Apr 3, 2014
    Posts:
    28
    hey @omrip32 , currently i am working with aws services right now using unity, but only some services availble from aws for unity. And our backend programmer using cloudfront to generate private s3 url (for security reason), and when i find aws sdk for unity, there is no cloudfront sample or docs in aws page or github. So i conclude, for right now, i can not implement cloudfront in unity. But in .NET, all core are availble to implement. And i want to know, if unity can import aws core sdk from .NET to unity, because i think, in structure, unity part from .NET, and i think it is possible but i don't know how to do that. Maybe you have the answer. Thanks