我试图在Windows机器上运行此代码。我想在我的node.js应用程序中使用Java Keytool。
var KEYTOOL_COMMAND="C:\\Program Files (x86)\\Java\\jre1.8.0_31 \\bin\\keytool";
var ktArgs = ["-genkey", "-v", "-keystore", "test1.keystore", "-alias", "test", "-keyalg", "RSA", "-keysize" ,"2048", "-validity", "10000"];
var spawn = require("child_process").spawn;
var cmd = spawn(KEYTOOL_COMMAND, ktArgs);
cmd.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
cmd.stderr.setEncoding('utf8');
cmd.stderr.on('data', function (data) {
cmd.stdin.write("password\n");
});
cmd.on('close', function (code) {
console.log('child process exited with code ' + code);
});
但是代码给了我这个错误。代码有什么问题?
C:\Users\nazır\Desktop\keytool>node index.js
stdout: keytool error: java.lang.RuntimeException: Too many retries, program terminated
stdout: java.lang.RuntimeException: Too many retries, program terminated
at sun.security.tools.keytool.Main.getX500Name(Unknown Source)
at sun.security.tools.keytool.Main.doGenKeyPair(Unknown Source)
at sun.security.tools.keytool.Main.doCommands(Unknown Source)
at sun.security.tools.keytool.Main.run(Unknown Source)
at sun.security.tools.keytool.Main.main(Unknown Source)
child process exited with code 1