mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Disable the ability to create synchronizable keys for now. Requires entitlements on the generate tool which is a giant pain in the rear. Tweak the output a bit more so it's nice and consistent.
This commit is contained in:
1 file changed
+36
-35
+36
-35
@@ -16,12 +16,12 @@ func findPublicKey() -> Data? {
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
kSecAttrProtocol as String: kSecAttrProtocolSSH,
|
||||
kSecAttrSynchronizableAny as String: kCFBooleanTrue,
|
||||
// kSecAttrSynchronizableAny as String: kCFBooleanTrue,
|
||||
kSecReturnData as String: kCFBooleanTrue,
|
||||
] as CFDictionary, &item)
|
||||
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
print("OK! Read the existing key saved in the Keychain.")
|
||||
// print("OK! Read the existing key saved in the Keychain.")
|
||||
return keys[64...]
|
||||
} else if res == errSecItemNotFound {
|
||||
return nil
|
||||
@@ -71,13 +71,13 @@ func generateKeyPair(makeSyncable: Bool) -> Data {
|
||||
kSecAttrComment as String: "Public key (SUPublicEDKey value) for this key is:\n\n\(publicEdKey.base64EncodedString())",
|
||||
kSecAttrDescription as String: "private key",
|
||||
|
||||
kSecAttrSynchronizable as String: (makeSyncable ? kCFBooleanTrue : kCFBooleanFalse)!,
|
||||
// kSecAttrSynchronizable as String: (makeSyncable ? kCFBooleanTrue : kCFBooleanFalse)!,
|
||||
] as CFDictionary
|
||||
|
||||
let res = SecItemAdd(query, nil)
|
||||
|
||||
if res == errSecSuccess {
|
||||
print("OK! A new key has been generated and saved in the Keychain.")
|
||||
// print("OK! A new key has been generated and saved in the Keychain.")
|
||||
return publicEdKey
|
||||
} else if res == errSecDuplicateItem {
|
||||
print("\nERROR: You already have a previously generated key in the Keychain")
|
||||
@@ -90,19 +90,16 @@ func generateKeyPair(makeSyncable: Bool) -> Data {
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let startEsc: String, endEsc: String
|
||||
if isatty(STDOUT_FILENO) != 0 {
|
||||
startEsc = "\u{001b}[91m"
|
||||
endEsc = "\u{001b}[m"
|
||||
} else {
|
||||
startEsc = ""
|
||||
endEsc = ""
|
||||
}
|
||||
|
||||
print("""
|
||||
This tool uses the macOS Keychain to store a private key for signing app updates
|
||||
which will be distributed via Sparkle. The key will be associated with your user
|
||||
account. If you have iCloud Keychain enabled, the key may optionally be marked as
|
||||
//let startEsc: String, endEsc: String
|
||||
//if isatty(STDOUT_FILENO) != 0 {
|
||||
// startEsc = "\u{001b}[91m"
|
||||
// endEsc = "\u{001b}[m"
|
||||
//} else {
|
||||
// startEsc = ""
|
||||
// endEsc = ""
|
||||
//}
|
||||
/*
|
||||
If you have iCloud Keychain enabled, the key may optionally be marked as
|
||||
syncable so it will be available on all devices logged into your iCloud account.
|
||||
|
||||
\(startEsc)WARNING: Making a signing key syncable is NOT recommended!\(endEsc)
|
||||
@@ -111,6 +108,11 @@ print("""
|
||||
key should your local account data become lost or corrupted; loss of the key makes
|
||||
it impossible to release updates that will be accepted by Sparkle.
|
||||
|
||||
*/
|
||||
print("""
|
||||
This tool uses the macOS Keychain to store a private key for signing app updates which
|
||||
will be distributed via Sparkle. The key will be associated with your user account.
|
||||
|
||||
Note: You only need one signing key, no matter how many apps you embed Sparkle in.
|
||||
|
||||
The keychain may ask permission for this tool to access an existing key, if one
|
||||
@@ -130,27 +132,26 @@ if let pubKey = findPublicKey() {
|
||||
|
||||
""")
|
||||
} else {
|
||||
print("""
|
||||
A new signing key will be generated.
|
||||
|
||||
Do you want to allow syncing the key to iCloud? [y/N]
|
||||
""")
|
||||
var makeSyncable: Bool? = nil
|
||||
while makeSyncable == nil {
|
||||
guard let response = readLine(strippingNewline: true) else { fatalError("EOF on stdin; can not continue") }
|
||||
switch response.lowercased() {
|
||||
case "y", "yes": makeSyncable = true
|
||||
case "n", "no", "": makeSyncable = false
|
||||
default: print("Unknown response. Allow key to sync to iCloud? [y/N]")
|
||||
}
|
||||
}
|
||||
|
||||
print("Generating a new signing key. This may take a moment, depending on your machine.")
|
||||
// print("A new signing key will be generated.")
|
||||
//
|
||||
// print("""
|
||||
// Do you want to allow syncing the key to iCloud? [y/N]
|
||||
// """)
|
||||
// var makeSyncable: Bool? = nil
|
||||
// while makeSyncable == nil {
|
||||
// guard let response = readLine(strippingNewline: true) else { fatalError("EOF on stdin; can not continue") }
|
||||
// switch response.lowercased() {
|
||||
// case "y", "yes": makeSyncable = true
|
||||
// case "n", "no", "": makeSyncable = false
|
||||
// default: print("Unknown response. Allow key to sync to iCloud? [y/N]")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// print("Generating a new signing key. This may take a moment, depending on your machine.")
|
||||
|
||||
let pubKey = generateKeyPair(makeSyncable: makeSyncable!)
|
||||
let pubKey = generateKeyPair(makeSyncable: false)
|
||||
|
||||
print("""
|
||||
|
||||
A key has been generated and saved in your keychain. Add the `SUPublicEDKey` key to
|
||||
the Info.plist of each app for which you intend to use Sparkle for distributing
|
||||
updates. It should appear like this:
|
||||
|
||||
Reference in new issue
Block a user