mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
Use ssh-keygen to generate the ssh keys
At some point I'll figure out how to do this with Dart only code, but till then lets just call the process. GitJournal can also no longer run in a sandbox as it needs to access the ssh-keygen executable.
This commit is contained in:
@ -25,10 +25,11 @@ class SshKey {
|
||||
final bool useDartKeyGen = false;
|
||||
|
||||
Future<SshKey?> generateSSHKeys({required String comment}) async {
|
||||
if (useDartKeyGen) {
|
||||
//return generateSSHKeysDart(comment: comment);
|
||||
} else {}
|
||||
return generateSSHKeysNative(comment: comment);
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
return generateSSHKeysNative(comment: comment);
|
||||
} else {
|
||||
return generateSSHKeysKeygen(comment: comment);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -80,6 +81,37 @@ Future<SshKey?> generateSSHKeysNative({required String comment}) async {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<SshKey?> generateSSHKeysKeygen({required String comment}) async {
|
||||
var privateFile = p.join(Directory.systemTemp.path, 'id_rsa');
|
||||
|
||||
// ssh-keygen -f /tmp/r -t rsa -b 4096 -q -N "" -C 'happy'
|
||||
var process = await Process.start('ssh-keygen', [
|
||||
'-f',
|
||||
privateFile,
|
||||
'-t',
|
||||
'rsa',
|
||||
'-b',
|
||||
'4096',
|
||||
'-q',
|
||||
'-N',
|
||||
'',
|
||||
'-C',
|
||||
comment,
|
||||
]);
|
||||
|
||||
var exitCode = await process.exitCode;
|
||||
if (exitCode != 0) {
|
||||
// FIXME: Give me an error!
|
||||
return null;
|
||||
}
|
||||
|
||||
return SshKey(
|
||||
publicKey: await File(privateFile + '.pub').readAsString(),
|
||||
privateKey: await File(privateFile).readAsString(),
|
||||
password: "",
|
||||
);
|
||||
}
|
||||
|
||||
Future<SshKey> generateSSHEccKeys({required String comment}) async {
|
||||
print("Generating KeyPair ...");
|
||||
var stopwatch = Stopwatch()..start();
|
||||
|
@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<false/>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
|
@ -3,6 +3,6 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
Reference in New Issue
Block a user