添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I am trying to change the custom certificate handler for my Android build so it will accept the self-signed cert on my server. I have created a script that Extends Unity.Networking.CertificateHandler per the several examples floating around that accept a specific public key. My version looks like this:

using UnityEngine.Networking;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
// Based on https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning#.Net
class AcceptANGCertificate : CertificateHandler
    // Encoded RSAPublicKey
    private static string PUB_KEY = "blahblahblahkeyishere";
    protected override bool ValidateCertificate(byte[] certificateData)
        X509Certificate2 certificate = new X509Certificate2(certificateData);
        string pk = certificate.GetPublicKeyString();
        //Uncomment to find public key.
        //Debug.Log(pk);
        if (pk.ToLower().Equals(PUB_KEY.ToLower()))
            return true;
        return false;

However, when I try to assign this handler to the CustomCertificateHander field in the AddressablesSettings asset, the list is never populated. I’ve tried renaming my script, and upgrading the Addressable Package to the latest. I’m stumped.

Addressables 1.19.13 (same issue with 1.16.19)
Unity 2019.4.20 LTS

thanks…

forzabo:

I am trying to change the custom certificate handler for my Android build so it will accept the self-signed cert on my server. I have created a script that Extends Unity.Networking.CertificateHandler per the several examples floating around that accept a specific public key. My version looks like this:

using UnityEngine.Networking;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
// Based on https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning#.Net
class AcceptANGCertificate : CertificateHandler
    // Encoded RSAPublicKey
    private static string PUB_KEY = "blahblahblahkeyishere";
    protected override bool ValidateCertificate(byte[] certificateData)
        X509Certificate2 certificate = new X509Certificate2(certificateData);
        string pk = certificate.GetPublicKeyString();
        //Uncomment to find public key.
        //Debug.Log(pk);
        if (pk.ToLower().Equals(PUB_KEY.ToLower()))
            return true;
        return false;

However, when I try to assign this handler to the CustomCertificateHander field in the AddressablesSettings asset, the list is never populated. I’ve tried renaming my script, and upgrading the Addressable Package to the latest. I’m stumped.

Addressables 1.19.13 (same issue with 1.16.19)
Unity 2019.4.20 LTS

thanks…

Your custom class should be visible for UnityEditor.AddressableAssets.Settings
The easiest way is to make it public

public class AcceptANGCertificate : CertificateHandler