Fix for certificatePath which includes spaces

This commit is contained in:
WiredSpast 2022-04-10 13:57:20 +02:00 committed by GitHub
parent b1f86aa80b
commit 3d6e7d5b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ public class NitroWindows implements NitroOsFunctions {
@Override @Override
public boolean isRootCertificateTrusted(File certificate) { public boolean isRootCertificateTrusted(File certificate) {
try { try {
final String output = RuntimeUtil.getCommandOutput(new String[] {"cmd", "/c", " certutil.exe -f -verify " + certificate.getAbsolutePath()}); final String output = RuntimeUtil.getCommandOutput(new String[] {"cmd", "/c", " certutil.exe -f -verify \"" + certificate.getAbsolutePath() + "\""});
return !output.contains("CERT_TRUST_IS_UNTRUSTED_ROOT") && return !output.contains("CERT_TRUST_IS_UNTRUSTED_ROOT") &&
output.contains("dwInfoStatus=10c dwErrorStatus=0"); output.contains("dwInfoStatus=10c dwErrorStatus=0");
@ -41,7 +41,7 @@ public class NitroWindows implements NitroOsFunctions {
final String certificatePath = certificate.getAbsolutePath(); final String certificatePath = certificate.getAbsolutePath();
// Prompt UAC elevation. // Prompt UAC elevation.
WinDef.HINSTANCE result = NitroWindowsShell32.INSTANCE.ShellExecuteA(null, "runas", "cmd.exe", "/S /C \"certutil -addstore root " + certificatePath + "\"", null, 1); WinDef.HINSTANCE result = NitroWindowsShell32.INSTANCE.ShellExecuteA(null, "runas", "cmd.exe", "/S /C 'certutil -addstore root \"" + certificatePath + "\"'", null, 1);
// Wait for exit. // Wait for exit.
Kernel32.INSTANCE.WaitForSingleObject(result, WinBase.INFINITE); Kernel32.INSTANCE.WaitForSingleObject(result, WinBase.INFINITE);