Can't get thigs working on WP8 with Unity3D

0 votes
Here is my code, it works perfectly in unity editor with PC build settings. I am using version 2.7.2.


public class ShephertzInterface : MonoBehaviour, App42CallBack {

    void Start()
        ServiceAPI serviceAPI = new ServiceAPI("KEY1","KEY2");  //Keys are of course something else...

        if (serviceAPI == null)
            Debug.LogError("ServiceApi is null");
        UserService userService = serviceAPI.BuildUserService();

        string username = "helloworld";
        string password = "helloworld";

        if (userService == null)
            Debug.LogError("UserService is null");

        //userService.CreateUser(username, password, "", this);
        userService.Authenticate(username, password, this);

    public void OnException (System.Exception exception)

    public void OnSuccess(object response)
        Debug.LogError("Success: " + response.ToString());

When using WP8 mode I use WP8 version of dll. When running in editor I get this kind of exception:

App42Exception: System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
  at Mono.Security.Protocol.Tls.RecordProtocol.ProcessAlert (AlertLevel alertLevel, AlertDescription alertDesc) [0x00000] in <filename unknown>:0
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  at com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWP8.GetResponseCallback (IAsyncResult asynchronousResult) [0x00000] in <filename unknown>:0
ShephertzInterface:OnException(Exception) (at Assets/Core/Scripts/ShephertzInterface.cs:39)

And when running in phone just:

App42Exception: Object not set to an instance of an object. //Comes from OnException
asked Jun 2, 2014 in App42 Cloud API-BaaS by niko.elmari (15 points)

1 Answer

+1 vote
Best answer

 You just have to use X509Certificates validator like this :-

using System.Net;

public static bool Validator (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
         {return true;}
void Start ()
   ServicePointManager.ServerCertificateValidationCallback = Validator;
ServiceAPI serviceAPI = new ServiceAPI("KEY1","KEY2");

This is also mentioned in README of the SDK.

Use #if tag as i used, otherwise it'll give error on device.

If your issue still exists or any other query,  feel free to ask us.

answered Jun 2, 2014 by Akshay.Mishra (179 points)
selected Jun 2, 2014 by niko.elmari
Thanks for you answer. Ok now it works with editor but I am still getting "App42Exception: Object not set to an instance of an object." with phone.
This is because maybe you are missing something, or device internet connectivity.
Yea phone hasn't access to the internet. That was the first thing that I checked but thanks for broser cache its just _seems_ to work. Also it was little confusing that without internet access editor give diffrent kind of error "App42Exception: System.Net.WebException: Error: NameResolutionFailure". After that my phone has also wrong time but now its working. Thanks!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on