From f9ecad1cf0ff730b8f964e8df125ce4c1d90915c Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 21 Oct 2022 15:18:16 +0800 Subject: [PATCH] Update download system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加证书认证方法 --- .../YooAsset/Runtime/DownloadSystem/DownloadSystem.cs | 7 +++++++ .../DownloadSystem/Downloader/FileDownloader.cs | 6 ++++++ Assets/YooAsset/Runtime/YooAssets.cs | 11 ++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs index ec62407..9459c41 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs @@ -2,6 +2,7 @@ using System.IO; using System.Collections; using System.Collections.Generic; +using UnityEngine.Networking; namespace YooAsset { @@ -15,6 +16,12 @@ namespace YooAsset private static readonly Dictionary _downloaderDic = new Dictionary(); private static readonly List _removeList = new List(100); + + /// + /// 自定义的证书认证实例 + /// + public static CertificateHandler CertificateHandlerInstance; + /// /// 启用断点续传功能文件的最小字节数 /// diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs index 4c0ae44..30c2967 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs @@ -89,6 +89,12 @@ namespace YooAsset _downloadHandle = handler; #endif + if (DownloadSystem.CertificateHandlerInstance != null) + { + _webRequest.certificateHandler = DownloadSystem.CertificateHandlerInstance; + _webRequest.disposeCertificateHandlerOnDispose = false; + } + _webRequest.downloadHandler = handler; _webRequest.disposeDownloadHandlerOnDispose = true; if (fileLength > 0) diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 3f68b89..e9b376e 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -161,7 +161,16 @@ namespace YooAsset { DownloadSystem.ClearFileResponseCodes = codes; } - + + /// + /// 设置下载系统参数,自定义的证书认证实例 + /// + /// + public static void SetDownloadSystemCertificateHandler(UnityEngine.Networking.CertificateHandler instance) + { + DownloadSystem.CertificateHandlerInstance = instance; + } + /// /// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒) ///