Secure connection between photon server and a client

Options
Hello,

I'm using marmalade and C++ with photon, I would like to create a secure connection between the server and the client, but each time I try to start it with
establishEncryption()
, an error occured (can't etablish connection with default region or something like that). Is there any tutorial or an example to run it correctly ?
Another question : once the connection is encrypted, does opRaiseEvent send informations in a readable mode or encrypted ?

Comments

  • Kaiserludi
    Options
    Hi He2.

    Sorry for not answering earlier.

    Unless you recompile LoadBalancing-cpp with SEND_AUTHENTICATE_ENCRYPTED set to false, the authentication flow that is triggered by your call to connect() will automatically include a call to establishEncryption(), so you normally don't have to establish encryption explicitly, but on default it will always automatically have been established by the time you get the callback that you are successfully connected.

    The error that you are getting sounds a bit like it may be caused by an attempt to call that function before being fully connected, but I am not sure, as I can't reproduce that error.

    Even when the connection is encrypted, opRaiseEvent() still only sends plain not encrypted data, as normally ingame data does not need to be transferred encrypted and just encrypting everything will cause a significant and usually unneeded overhead.



    However you could easily modify opRaiseEvent() to let it use encryption. To achieve this, just navigate to LoadBalancing-cpp/src/Peer.cpp inside the Photon Client SDK and in there navigate to Peer::opRaiseEvent(). The last line of that function is a call to PhotonPeer::opCustom(). opCustom() takes an optional parameter 'useEncryption'. So if you add a ", true" after the channelID, then that will make opRaiseEven encrypt everything its sends (after rebuilding LoadBalancing-cpp, of course).

    You may want to add another bool parameter 'sendEncrypted' to opRaiseEvent() and let it route the value of that parameter to opCustom(), so that you can decide on a per-call basis if opSendEvent() should sen a certain message encrypted or not, so that you don't have to send everything encrypted.
  • He2
    Options
    Thanks for the answer, I've tried to re-compile photon (with visual studio 2012) but everytime the process call nant it crashes. So i've tried to download the source code from your website and... same result ! I had to rewrite the function by copy/paste a few things from LoadBalancing-cpp/src/Peer.cpp

    Thanks