gpt4 book ai didi

c# - 如何修复 UNITYTLS_X509VERIFY_NOT_DONE

转载 作者:行者123 更新时间:2023-12-04 22:42:41 27 4
gpt4 key购买 nike

我已经看到了几个类似错误的答案,但不是我的具体错误。最好的例子是 Remy 对 UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED 的回答。
我的错误如下:TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE

  • Web API Node.js/MongoDB
  • NGINX 与 CertBot
  • SSL LetsEncrypt 与 fullchain.pem 中的链式证书

  • NGINX 默认
    listen [::]:443 ssl ipv6only=on #managed by Certbot
    listen 443 ssl
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privatekey.pem # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem # managed by Certbot

    根据 Unity Docs,我使用了 CertificateHandler类(class)
        internal class RequestCertificate : CertificateHandler
    {

    private static string PUB_KEY = "SOME public key";


    protected override bool ValidateCertificate(byte[] certificateData)
    {
    X509Certificate2 certificate = new X509Certificate2(certificateData);
    string pk = certificate.GetPublicKeyString();
    if (pk.Equals(PUB_KEY))
    {
    Debug.Log("Validate Certificate");

    return true;
    }
    else
    {
    Debug.Log("Not Validate Certificate");

    return false;
    }

    }
    }
    我的注册方法
    protected IEnumerator Register()
    {
    List<IMultipartFormSection> wwwForm = new List<IMultipartFormSection>();
    wwwForm.Add(new MultipartFormDataSection("name", uName.text));
    wwwForm.Add(new MultipartFormDataSection("email", uEmail.text));
    wwwForm.Add(new MultipartFormDataSection("screenName", uScreenName.text));
    wwwForm.Add(new MultipartFormDataSection("password", uConPass.text));

    UnityWebRequest www = UnityWebRequest.Post(EndPointManager.API_URL + "users/store-user", wwwForm);
    www.certificateHandler = new RequestCertificate();
    Debug.Log(www.certificateHandler.GetHashCode());
    yield return www.SendWebRequest();

    if (www.isNetworkError || www.isHttpError)
    {
    Debug.Log(www.error); // OUTPUT: Unable to complete SSL connection
    debugText.text += $"\n HTTP ERROR: {www.error} \n";
    }
    else
    {
    debugText.text += "Success";
    }
    }

    最佳答案

    这与证书颁发机构或 NGINX 无关。我决定设置一个前端表单来测试 Chrome 中的这个错误,一旦我这样做了,答案就打在了我的脸上。我忘记在生产服务器上设置环境变量并得到net::ERR_SSL_PROTOCOL_ERROR .由于 Unity 返回了一个我不熟悉的错误,我不知道如何处理它。
    我让我的 app.js 文件在寻找 process.env.NODE_ENV所以它可以设置protocol = 'https'但没有设置它。我一做 Node.js 就使用了 https.createServer(app)而不是 http.crateServer(app)一切都很好。

    关于c# - 如何修复 UNITYTLS_X509VERIFY_NOT_DONE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64493528/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com