Rewrite cert generation and fix bad cert

This commit is contained in:
Xpl0itU 2024-04-20 17:44:14 +02:00
parent ba6ff5d548
commit f4eee481fe
4 changed files with 24 additions and 42 deletions

View file

@ -2,10 +2,8 @@ package wiiudownloader
import (
"context"
"encoding/binary"
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
@ -211,25 +209,13 @@ func DownloadTitle(titleID, outputDirectory string, doDecryption bool, progressR
progressReporter.SetDownloadSize(int64(titleSize))
cert, err := GenerateCert(tmd, progressReporter, client)
if err != nil {
if err := GenerateCert(tmd, filepath.Join(outputDir, "title.cert"), progressReporter, client); err != nil {
if progressReporter.Cancelled() {
return nil
}
return err
}
certPath := filepath.Join(outputDir, "title.cert")
certFile, err := os.Create(certPath)
if err != nil {
return err
}
if err := binary.Write(certFile, binary.BigEndian, cert.Bytes()); err != nil {
return err
}
certFile.Close()
log.Printf("Certificate saved to %v \n", certPath)
g, ctx := errgroup.WithContext(context.Background())
g.SetLimit(maxConcurrentDownloads)
sem := semaphore.NewWeighted(maxConcurrentDownloads)