示例#1
0
        private static List <SslCertBundle> DownloadCertBundles(UrlDownloaderConfig dlConfig)
        {
            List <SslCertBundle> dlBundles = new List <SslCertBundle>();
            List <string>        list      = new List <string>();

            if (BattleNet.Client().GetMobileEnvironment() != constants.MobileEnv.PRODUCTION)
            {
                list.Add("http://nydus-qa.web.blizzard.net/Bnet/zxx/client/bgs-key-fingerprint");
            }
            list.Add("http://nydus.battle.net/Bnet/zxx/client/bgs-key-fingerprint");
            IUrlDownloader urlDownloader         = BattleNet.Client().GetUrlDownloader();
            int            numDownloadsRemaining = list.Count;

            foreach (string url in list)
            {
                urlDownloader.Download(url, delegate(bool success, byte[] bytes)
                {
                    if (success)
                    {
                        SslCertBundle item = new SslCertBundle(bytes);
                        dlBundles.Add(item);
                    }
                    numDownloadsRemaining--;
                }, dlConfig);
            }
            while (numDownloadsRemaining > 0)
            {
                Thread.Sleep(15);
            }
            return(dlBundles);
        }
        private static List <SslCertBundle> DownloadCertBundles(UrlDownloaderConfig dlConfig)
        {
            List <SslCertBundle> sslCertBundles = new List <SslCertBundle>();
            List <string>        strs           = new List <string>();

            if (BattleNet.Client().GetMobileEnvironment() != constants.MobileEnv.PRODUCTION)
            {
                strs.Add("http://nydus-qa.web.blizzard.net/Bnet/zxx/client/bgs-key-fingerprint");
            }
            strs.Add("http://nydus.battle.net/Bnet/zxx/client/bgs-key-fingerprint");
            IUrlDownloader urlDownloader = BattleNet.Client().GetUrlDownloader();
            int            count         = strs.Count;

            foreach (string str in strs)
            {
                urlDownloader.Download(str, (bool success, byte[] bytes) => {
                    if (success)
                    {
                        SslCertBundle sslCertBundle = new SslCertBundle(bytes);
                        sslCertBundles.Add(sslCertBundle);
                    }
                    count--;
                }, dlConfig);
            }
            while (count > 0)
            {
                Thread.Sleep(15);
            }
            return(sslCertBundles);
        }
        public void Download(string url, UrlDownloadCompletedCallback cb, UrlDownloaderConfig config)
        {
            WebRequest request = WebRequest.Create(url);

            DotNetUrlDownloader.DownloadResult downloadResult = new DotNetUrlDownloader.DownloadResult();
            downloadResult.callback = cb;
            DotNetUrlDownloader.Download(new DotNetUrlDownloader.DownloadState
            {
                downloader     = this,
                host           = url,
                downloadResult = downloadResult,
                request        = request,
                numRetriesLeft = config.numRetries,
                timeoutMs      = config.timeoutMs
            });
        }
示例#4
0
 private static bool OnValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
 {
     SslSocket.CertValidationResult certValidationResult = SslSocket.IsServerCertificateValid(sender, certificate, chain, sslPolicyErrors);
     if (certValidationResult == SslSocket.CertValidationResult.FAILED_CERT_BUNDLE)
     {
         SslStream key = (SslStream)sender;
         SslSocket.SslStreamValidateContext sslStreamValidateContext = SslSocket.s_streamValidationContexts[key];
         SslSocket            sslSocket            = sslStreamValidateContext.m_sslSocket;
         UrlDownloaderConfig  bundleDownloadConfig = sslSocket.m_bundleSettings.bundleDownloadConfig;
         List <SslCertBundle> list = SslSocket.DownloadCertBundles(bundleDownloadConfig);
         foreach (SslCertBundle sslCertBundle in list)
         {
             sslSocket.m_bundleSettings.bundle = sslCertBundle;
             certValidationResult = SslSocket.IsServerCertificateValid(sender, certificate, chain, sslPolicyErrors);
             if (certValidationResult == SslSocket.CertValidationResult.OK)
             {
                 FileUtil.StoreToDrive(sslCertBundle.CertBundleBytes, SslSocket.GetBundleStoragePath(), true, true);
                 break;
             }
         }
     }
     return(certValidationResult == SslSocket.CertValidationResult.OK);
 }
        public void Download(string url, UrlDownloadCompletedCallback cb)
        {
            UrlDownloaderConfig config = new UrlDownloaderConfig();

            this.Download(url, cb, config);
        }
示例#6
0
 public SslCertBundleSettings()
 {
     this.bundle = new SslCertBundle(null);
     this.bundleDownloadConfig = new UrlDownloaderConfig();
 }