public void setup() { _keyFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"FunctionalTests\Signing\KeyDir\manifest-key.xml"); _moduleDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"FunctionalTests\Signing\Module"); _assemblyName = "sample_module.dll"; _assemblyPath = Path.Combine(_moduleDirectory, _assemblyName); _manifestPath = _assemblyPath + ModuleManifest.ManifestFileNameSuffix; _issuerName = "test-issuer"; if (File.Exists(_keyFileName)) { File.Delete(_keyFileName); } KeysGenerator.KeysGeneratorProgram.Main(new[] { _keyFileName }); // creating sample assembly, cause the manifest generator requires full-fledgged assembly not imposter var compiler = new ModuleCompiler { OutputDirectory = _moduleDirectory, OutputName = _assemblyPath }; compiler.GenerateModuleFromCode(ModuleCompiler.DefaultSimpleModuleSource); // test creating the manifests ManifestCreatorProgram.Main(new[] { "rsa", _keyFileName, _moduleDirectory, _assemblyName, _issuerName }); }
public void generate_key_manifest() { _moduleDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Modules\signing\"); _assemblyName = "EmptyModule.dll"; _modulePath = Path.Combine(_moduleDirectory, _assemblyName); ManifestCreatorProgram.Main(new[] { "rsa", _keyFileName , _moduleDirectory, _assemblyName, _issuerName }); var mockFactory = new MockFactory(MockBehavior.Strict); _signatureProvider = mockFactory.Create <ISignatureProvider>(); _signatureProvider.Setup(x => x.GetIssuer(_issuerName)).Returns( new IssuerInformation(_issuerName, new RsaSignatureAlgorithm(File.ReadAllText(_publicKeyFileName)))); _filter = new SignatureModuleFilter(_signatureProvider.Object); _manifestPath = _modulePath + ModuleManifest.ManifestFileNameSuffix; _manifestSignature = _manifestPath + ModuleManifest.ManifestSignatureFileNameSuffix; _moduleContent = File.ReadAllBytes(_modulePath); }
private void CreateSignature(string key, string password) { if (File.Exists(_manifestPath)) { File.Delete(_manifestPath); } if (File.Exists(_manifestSignature)) { File.Delete(_manifestSignature); } ManifestCreatorProgram.Main(new[] { "pki", key, _moduleDirectory, _assemblyName, _issuerName, password }); }