Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Are X509Certificate2 classes only partially supported by unity?

Discussion in 'Scripting' started by Reahreic, Jul 17, 2023.

  1. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254
    I've been working around Unity refusing to return certificates in the LocalMachine > MY certificate store by locating the certificate using C++ and returning the located CertificateContext pointer to C#.

    the C++ DLL is able to return a managed pointer to the located certificate context, however when instantiating the certificate instance using the pointer, I get a "PlatformNotSupportedException"...

    System.PlatformNotSupportedException: Initializing `X509Certificate` from native handle is not supported.
    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor (System.IntPtr handle) [0x0001c]


    I know the C# code works as it's pulled from one of my .Net C# libraries. I've also decompiled the X509Certificate2 and X509Certificate classes and it appears they are implemented with in the .net/mono/il2cpp backend unity uses for Windows Standalone builds.
     
  2. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    162
    @Reahreic same problem here.. i noticed that it is working on Unity 2020 and not working on 2022 so seems to be a bug in native mono libs from Net.Framework