Skip to content

Commit

Permalink
Merge pull request #5 from GingerPrivacy/bugfix/notarization_ginger
Browse files Browse the repository at this point in the history
use notarytool with devId and teamId
  • Loading branch information
luzius1089 authored May 31, 2024
2 parents 063639f + f06550c commit 84b6896
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
12 changes: 6 additions & 6 deletions WalletWasabi.Packager/ArgsProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ private bool IsOneOf(params string[] values)
return false;
}

public (string AppleId, string Password) GetAppleIdAndPassword()
public (string AppleId, string TeamId) GetAppleAndTeamId()
{
string appleId = "";
string password = "";
string teamId = "";

try
{
var appleidArg = Args.First(a => a.Contains("appleid", StringComparison.InvariantCultureIgnoreCase));
var parameters = appleidArg.Split("=")[1];
var idAndPassword = parameters.Split(":");
appleId = idAndPassword[0];
password = idAndPassword[1];
var appleAndTeamId = parameters.Split(":");
appleId = appleAndTeamId[0];
teamId = appleAndTeamId[1];
}
catch (Exception)
{
}

return (appleId, password);
return (appleId, teamId);
}
}
4 changes: 2 additions & 2 deletions WalletWasabi.Packager/Content/Osx/App/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundleExecutable</key>
<string>wassabee</string>
<key>CFBundleName</key>
<string>Wasabi Wallet</string>
<string>Ginger Wallet</string>
<key>CFBundleIdentifier</key>
<string>zksnacks.wasabiwallet</string>
<string>gingerprivacy.gingerwallet</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSAppleScriptEnabled</key>
Expand Down
35 changes: 19 additions & 16 deletions WalletWasabi.Packager/MacSignTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@ public static void Sign(ArgsProcessor argsProcessor)
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string removableDriveFolder = Tools.GetSingleUsbDrive();

var srcZipFileNamePattern = "WasabiToNotarize-*";
var srcZipFileNamePattern = "GingerToNotarize-*";
var files = Directory.GetFiles(removableDriveFolder, srcZipFileNamePattern);
if (files.Length != 2)
{
throw new InvalidDataException($"{srcZipFileNamePattern} file missing or there are more! There must be exactly two!");
}

var (appleId, password) = argsProcessor.GetAppleIdAndPassword();
var (appleId, teamId) = argsProcessor.GetAppleAndTeamId();

while (string.IsNullOrWhiteSpace(appleId))
{
Console.WriteLine("Enter appleId (email):");
appleId = Console.ReadLine();
}

while (string.IsNullOrWhiteSpace(password))
while (string.IsNullOrWhiteSpace(teamId))
{
Console.WriteLine("Enter password:");
password = Console.ReadLine();
Console.WriteLine("Enter teamId:");
teamId = Console.ReadLine();
}

foreach (var zipPath in files)
{
var zipFile = Path.GetFileName(zipPath);
var versionPrefix = Path.GetFileNameWithoutExtension(zipPath).Split('-')[1]; // Example: "WasabiToNotarize-2.0.0.0-arm64.zip or WasabiToNotarize-2.0.0.0.zip ".
var workingDir = Path.Combine(desktopPath, "wasabiTemp");
var workingDir = Path.Combine(desktopPath, "gingerTemp");
var dmgPath = Path.Combine(workingDir, "dmg");
var unzippedPath = Path.Combine(workingDir, "unzipped");
var appName = $"{Constants.AppName}.app";
Expand All @@ -57,16 +57,18 @@ public static void Sign(ArgsProcessor argsProcessor)
var appResPath = Path.Combine(appContentsPath, "Resources");
var appFrameworksPath = Path.Combine(appContentsPath, "Frameworks");
var infoFilePath = Path.Combine(appContentsPath, "Info.plist");
var dmgFileName = zipFile.Replace("WasabiToNotarize", "Wasabi").Replace("zip", "dmg");
var dmgFileName = zipFile.Replace("GingerToNotarize", "Ginger").Replace("zip", "dmg");
var dmgFilePath = Path.Combine(workingDir, dmgFileName);
var dmgUnzippedFilePath = Path.Combine(workingDir, $"Wasabi.tmp.dmg");
var appNotarizeFilePath = Path.Combine(workingDir, $"Wasabi-{versionPrefix}.zip");
var dmgUnzippedFilePath = Path.Combine(workingDir, $"Ginger.tmp.dmg");
var appNotarizeFilePath = Path.Combine(workingDir, $"Ginger-{versionPrefix}.zip");
var contentsPath = Path.GetFullPath(Path.Combine(Program.PackagerProjectDirectory.Replace("\\", "//"), "Content", "Osx"));
var entitlementsPath = Path.Combine(contentsPath, "entitlements.plist");
var dmgContentsDir = Path.Combine(contentsPath, "Dmg");
var desktopDmgFilePath = Path.Combine(desktopPath, dmgFileName);

var signArguments = $"--sign \"L233B2JQ68\" --verbose --force --options runtime --timestamp";
// Save the app specific pw by using this command: xcrun notarytool store-credentials WasabiNotarize

var signArguments = $"--sign \"{teamId}\" --verbose --force --options runtime --timestamp";

Console.WriteLine("Phase: creating the working directory.");

Expand Down Expand Up @@ -169,7 +171,7 @@ public static void Sign(ArgsProcessor argsProcessor)

Console.WriteLine("Phase: verifying the signature.");

Verify(appPath);
Verify(appPath, teamId);

Console.WriteLine("Phase: notarize the app.");

Expand Down Expand Up @@ -236,7 +238,7 @@ public static void Sign(ArgsProcessor argsProcessor)
"create",
$"\"{dmgUnzippedFilePath}\"",
"-ov",
$"-volname \"Wasabi Wallet\"",
$"-volname \"Ginger Wallet\"",
"-fs HFS+",
$"-srcfolder \"{dmgPath}\""
});
Expand Down Expand Up @@ -277,7 +279,7 @@ public static void Sign(ArgsProcessor argsProcessor)

Console.WriteLine("Phase: verifying the signature.");

Verify(dmgFilePath);
Verify(dmgFilePath, teamId);

Console.WriteLine("Phase: notarize dmg");
Notarize(appleId, dmgFilePath);
Expand Down Expand Up @@ -331,7 +333,6 @@ private static void Notarize(string appleId, string filePath)
{
Console.WriteLine("Start notarizing, uploading file.");

// -p WasabiNotarize = Saved the credentials in the keychain profile which keeps the password safe on the local machine. Name of the profile is "WasabiNotarize".
using var process = Process.Start(new ProcessStartInfo
{
FileName = "xcrun",
Expand Down Expand Up @@ -393,7 +394,7 @@ private static void SignFile(string arguments, string workingDir)
Console.WriteLine(result.Trim());
}

private static void Verify(string path)
private static void Verify(string path, string teamId)
{
using var process = Process.Start(new ProcessStartInfo
{
Expand All @@ -403,7 +404,9 @@ private static void Verify(string path)
});
var nonNullProcess = WaitProcessToFinish(process, "codesign");
string result = nonNullProcess.StandardError.ReadToEnd();
if (!result.Contains("Authority=Developer ID Application: zkSNACKs Ltd."))

// Contains the TEAM-ID.
if (!result.Contains(teamId))
{
throw new InvalidOperationException(result);
}
Expand Down

0 comments on commit 84b6896

Please sign in to comment.