zhangjiannan 2025-06-17 12:45:22 +08:00
parent 3443be1d0c
commit 8a79929f66
4 changed files with 30 additions and 36 deletions

View File

@ -9,6 +9,8 @@ using System.Collections.Generic;
using UnityEngine;
using GameCore;
using System.Text.RegularExpressions;
using UnityEngine.Networking;
namespace ResUpdate
{
public enum DownLoadType
@ -284,13 +286,15 @@ namespace ResUpdate
{
if (!string.IsNullOrEmpty(httpsReg.Match(url).ToString()))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ResourceDownloadManager.CheckValidationResult);
ServicePointManager.CheckCertificateRevocationList = true;
ServicePointManager.Expect100Continue = false;
ServicePointManager.ServerCertificateValidationCallback = ResourceDownloadManager.CheckValidationResult;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls|SecurityProtocolType.Tls12;
}
var stringBuilder = new StringBuilder();
var fullUrl = stringBuilder.Append(url).Append(fileName).ToString();
webRequest = (HttpWebRequest)WebRequest.Create(fullUrl);
Debug.LogError("url :" + fullUrl);
if (downLoadType == DownLoadType.CacheResumeFile)

View File

@ -224,7 +224,30 @@ namespace ResUpdate
/// <returns></returns>
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
bool isOk = true;
// If there are errors in the certificate chain,
// look at each error to determine the cause.
if (errors != SslPolicyErrors.None)
{
for (int i = 0; i < chain.ChainStatus.Length; i++)
{
if (chain.ChainStatus[i].Status == X509ChainStatusFlags.RevocationStatusUnknown)
{
continue;
}
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 1, 0);
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
bool chainIsValid = chain.Build((X509Certificate2)certificate);
if (!chainIsValid)
{
isOk = false;
break;
}
}
}
return isOk;
}
/// <summary>

View File

@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 3ed5c128ca330e74490283f99fd1ec5c
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant: