**Kibana version:**  8.3 Snapshot Kibana self-managed environment

**Host OS and Browser version:** Windows, All

**Build details:**
```
VERSION: 8.3.0 Snapshot self-managed
BUILD: 52512
COMMIT: df225b213b188c81888141cee2ec191424fc0649
Elasticsearch artifact link: https://snapshots.elastic.co/8.3.0-6ba9f710/downloads/elasticsearch/elasticsearch-8.3.0-SNAPSHOT-windows-x86_64.zip
```

**Preconditions:**
1. 8.3 Snapshot Kibana self-managed environment should be available.

**Steps to reproduce:**
1. Navigate to `C:\elk\elasticsearch\bin>` through cmd.
2. Run below command:
`elasticsearch-certutil ca --pem`
3. Observe Java exceptions on running cert creation command.

**Expected Result:**
 CA cert should be created on running `elasticsearch-certutil ca --pem` command.

**Screenshot:**
![1](https://user-images.githubusercontent.com/77374876/167078819-20c28e8e-5886-443f-8ab7-1e58d80fb1e2.JPG)


distribution/tools/cli-launcher/src/test/java/org/elasticsearch/launcher/CliToolLauncherTests.java
assertThat(getToolName(Map.of("cli.name", "mycli")), equalTo("mycli"));
    }
    public void testScriptNameSysprop() {
        var sysprops = Map.of("cli.name", "", "cli.script", "/foo/bar/elasticsearch-mycli", "os.name", "Linux");
        assertThat(getToolName(sysprops), equalTo("mycli"));
    }
    public void testScriptNameSyspropWindows() {
        var sysprops = Map.of("cli.name", "", "cli.script", "C:\\foo\\bar\\elasticsearch-mycli.bat", "os.name", "Windows XP");
        assertThat(getToolName(sysprops), equalTo("mycli"));
    }
    public void testShutdownHook() {
        MockTerminal terminal = MockTerminal.create();
        AtomicBoolean closeCalled = new AtomicBoolean();
        Closeable toClose = () -> { closeCalled.set(true); };
        Thread hook = createShutdownHook(terminal, toClose);
        hook.run();
        assertThat(closeCalled.get(), is(true));
        assertThat(terminal.getErrorOutput(), emptyString());
    }
    public void testShutdownHookError() {
        MockTerminal terminal = MockTerminal.create();
        Closeable toClose = () -> { throw new IOException("something bad happened"); };
        Thread hook = createShutdownHook(terminal, toClose);
        hook.run();
        assertThat(terminal.getErrorOutput(), containsString("something bad happened"));
        
        assertThat(terminal.getErrorOutput(), containsString("at org.elasticsearch.launcher.CliToolLauncherTests.lambda"));
    }
}