diff --git a/NUS Downloader/CertificateChain.cs b/NUS Downloader/CertificateChain.cs index d9f7145..b2e7634 100644 --- a/NUS Downloader/CertificateChain.cs +++ b/NUS Downloader/CertificateChain.cs @@ -121,6 +121,18 @@ namespace libWiiSharp return FromTikTmd(File.ReadAllBytes(pathToTik), File.ReadAllBytes(pathToTmd)); } + /// + /// Grabs certificates from Ticket and Tmd. + /// Ticket and Tmd must contain certs! (They do when they're downloaded from NUS!) + /// + /// + /// + /// + public static CertificateChain FromTikTmd(string pathToTik, byte[] tmdFile) + { + return FromTikTmd(File.ReadAllBytes(pathToTik), tmdFile); + } + /// /// Grabs certificates from Ticket and Tmd. /// Ticket and Tmd must contain certs! (They do when they're downloaded from NUS!) @@ -209,6 +221,18 @@ namespace libWiiSharp LoadFromTikTmd(File.ReadAllBytes(pathToTik), File.ReadAllBytes(pathToTmd)); } + /// + /// Grabs certificates from Ticket and Tmd. + /// Ticket and Tmd must contain certs! (They do when they're downloaded from NUS!) + /// + /// + /// + /// + public void LoadFromTikTmd(string pathToTik, byte[] tmdFile) + { + LoadFromTikTmd(File.ReadAllBytes(pathToTik), tmdFile); + } + /// /// Grabs certificates from Ticket and Tmd. /// Ticket and Tmd must contain certs! (They do when they're downloaded from NUS!) diff --git a/NUS Downloader/NusClient.cs b/NUS Downloader/NusClient.cs index c2a3dd1..4b2d824 100644 --- a/NUS Downloader/NusClient.cs +++ b/NUS Downloader/NusClient.cs @@ -307,9 +307,11 @@ namespace libWiiSharp //Download TMD fireDebug(" Downloading TMD..."); TMD tmd; + byte[] tmdFileWithCerts; try { - tmd = TMD.Load(wcNus.DownloadData(titleUrl + tmdFile)); + tmdFileWithCerts = wcNus.DownloadData(titleUrl + tmdFile); + tmd = TMD.Load(tmdFileWithCerts); } catch (Exception ex) { fireDebug(" Downloading TMD Failed..."); throw new Exception("Downloading TMD Failed:\n" + ex.Message); } @@ -402,7 +404,7 @@ namespace libWiiSharp if (storeWad) { fireDebug(" Building Certificate Chain..."); - CertificateChain cert = CertificateChain.FromTikTmd(Path.Combine(outputDir, "cetk"), Path.Combine(outputDir, tmdFile)); + CertificateChain cert = CertificateChain.FromTikTmd(Path.Combine(outputDir, "cetk"), tmdFileWithCerts); byte[][] contents = new byte[tmd.NumOfContents][];