예제 #1
0
        private bool VerifySigned()
        {
            var leaf = GetLeafResponse();

            if (leaf.Published < SettingsHelper.CutOffDateTime)
            {
                return(false);
            }

            var folderName       = Path.Combine(Directory.GetCurrentDirectory(), $"{package.PackageId}-{LatestVersion.VersionString}");
            var nugetPackageName = Path.Combine(folderName, $"{package.PackageId}.{LatestVersion.VersionString}.nupkg");

            try
            {
                Directory.CreateDirectory(folderName);
                webClient.DownloadFile(leaf.PackageContentUrl, nugetPackageName);

                using (var aZipProc = new ZipProcessor(nugetPackageName))
                {
                    var filesToProcess = aZipProc.GetSignableFilesMS(folderName);

                    foreach (var aFile in filesToProcess)
                    {
                        if (!SigningProcessor.IsTrusted(aFile))
                        {
                            return(false);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                Directory.Delete(folderName, true);
            }

            return(true);
        }
        private async Task <bool> VerifySignedAsync()
        {
            var leaf = await GetLeafResponseAsync();

            if (leaf.Published < SettingsHelper.CutOffDateTime)
            {
                return(false);
            }

            var folderName       = Path.Combine(System.IO.Path.GetTempPath(), $"{package.PackageId}-{LatestVersion.VersionString}");
            var nugetPackageName = Path.Combine(folderName, $"{package.PackageId}.{LatestVersion.VersionString}.nupkg");

            try
            {
                Directory.CreateDirectory(folderName);
                await webClient.DownloadFileTaskAsync(leaf.PackageContentUrl, nugetPackageName);

                using (var aZipProc = new ZipProcessor(nugetPackageName))
                {
                    var filesToProcess = aZipProc.GetSignableFilesMS(folderName);

                    foreach (var aFile in filesToProcess)
                    {
                        if (!SigningProcessor.IsTrusted(aFile))
                        {
                            return(false);
                        }
                    }
                }
            }
            finally
            {
                Directory.Delete(folderName, true);
            }

            return(true);
        }