Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Validating a certificate in Hololens

I am currently building a project for Hololens, using Visual Studio and Unity3D. This project uses external dll's, among which RestSharp and Manatee.Json. My application uses those libraries to make calls to Trello's API in C#.

Curently, my project runs perfectly on Unity's "Play mode". However, when I try to build the project, I get the following error :

Assets\Scripts\Controller\RestController.cs(25,9): error CS0103: The name 'ServicePointManager' does not exist in the current context

Here is the incriminated line :

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

I believe I get the error because ServicePointManager is not part of .net Core, which is my build target.

I tried removing this line entirely, and the project manages to build properly. However, at runtime I get the following error :

TlsException: Invalid certificate received from server. Error code: 0xffffffff80092012
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates)

Googling the error yield solutions using the ServicePointManager.ServerCertificateValidationCallback method, which I can't use do due to .net Core restrictions.

What is the proper way to validate my certificate for Hololens ?


Curent Settings:

  • Unity 5.5.0f3 & HoloToolkit v 1.5.5.0
  • Build settings : SDK Universal 10, Target device Hololens, Build Type D3D
  • Compilation override : Use Net Core
  • On all my DLL's : Checkbox "Don't Process" ticked
Tagged:

Answers

  • Options
    james_ashleyjames_ashley ✭✭✭✭

    @Aserre,

    Definitely a .NET 3.5 vs .NETCore difference in handling certificates. I ran into this recently with the Windows Device Portal Wrapper. There's an article on validating certificates in UWP here that should be helpful.

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • Options
    ASerreASerre
    edited March 2017

    @james_ashley Thanks for the link! However, the solution uses async methods which requires C# 5. Is there a workaround that uses the version supported by unity ?

  • Options
    james_ashleyjames_ashley ✭✭✭✭

    @Aserre,

    There isn't really a workaround. You could, however, use conditional declarations to let the async calls get invoked in the runtime but not in the editor.

    #if UNITY_EDITOR
        Debug.Log("Unity Editor");
    #endif
    

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

Sign In or Register to comment.