private void GenerateDirectoryManifest() { string assemblyPath = null; var rsa = SnkUtil.GetRsaProvider(_snkFile); try { XmlSerializer s = new XmlSerializer(typeof(UpdateManifest)); string manifest = s.SerializeToString(_updateManifest, "urn:AVSyncer.Updates"); var signedManifestDoc = SignManifest(manifest); var sb = new System.Text.StringBuilder(); var settings = new System.Xml.XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }; using (var writer = System.Xml.XmlWriter.Create(sb, settings)) { signedManifestDoc.Save(writer); } StreamWriter sw = new StreamWriter(_manifestFile); sw.Write(sb.ToString()); sw.Close(); ZipFile zip = new ZipFile(_dir + ".zip"); zip.AddFile(_manifestFile, ""); zip.Save(); } finally { if (assemblyPath != null && File.Exists(assemblyPath)) { File.Delete(assemblyPath); } } }
public System.Xml.XmlDocument SignManifest(string rawXml) { System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); // Load an XML file into the XmlDocument object. xmlDoc.PreserveWhitespace = true; xmlDoc.LoadXml(rawXml); var rsa = SnkUtil.GetRsaProvider(_snkFile); // Sign the XML document. SignXml(xmlDoc, rsa); return(xmlDoc); }
private void EmitPublicKey() { var rsa = SnkUtil.GetRsaProvider(_snkFile); Console.WriteLine("{0}", rsa.ToXmlString(false)); }