Unity WebGL with Google API 不验证证书

问题描述 投票:0回答:0

我用于验证 Google API 的 SSL 证书的脚本在 WebGL 中不起作用。我尝试了几种方法,包括使用 JSON 格式,但我无法让它工作。目前,我使用的是 p12 格式。除 WebGL 外,桌面或编辑器中的所有测试均有效。我附上代码片段

IEnumerator LoadCertificate() { 字符串 certificatePahtTmp = Path.Combine(Application.streamingAssetsPath, certificateName); UnityWebRequest certificateTmp = UnityWebRequest.Get(certificatePahtTmp); yield return certificateTmp.SendWebRequest();

    if (certificateTmp.result != UnityWebRequest.Result.Success)
    {
        Debug.LogError("Failed");
    }
    else
    {

        Byte[] certificatebytes =  certificateTmp.downloadHandler.data;
         var certificate = new X509Certificate2(certificatebytes, "notasecret", X509KeyStorageFlags.Exportable);

        var credential = new ServiceAccountCredential(
        new ServiceAccountCredential.Initializer(serviceAccountEmail)
        {
            Scopes = new[] { SheetsService.Scope.Spreadsheets }
        }.FromCertificate(certificate));

        googleSheetsService = new SheetsService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "GoogleSheets API for Unity"
        });

}

“我试过更改证书类型,以及将内容复制到局部变量中。我也使用了 GoogleCredential,但同样的问题出现在 WebGL 中。此外,我在 Google 中创建了不同的密钥并授予了不同的权限API,但问题仍然存在。”

c# google-cloud-platform unity-webgl
© www.soinside.com 2019 - 2024. All rights reserved.