We generate certificates that are intended to be used for server authentication in a couple of places:

- `bin/elasticsearch-certutil http` command  ( See `CertGenUtils.generateSignedCertificate` in `HttpCertificateCommand` )
- TLS auto-configuraion for node startup ( see [`AutoConfigureNode`](https://github.com/elastic/elasticsearch/blob/814f7f9f52cb8c05db6465b9bfc818ea5d76c575/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/AutoConfigureNode.java#L454) )

In these cases we know that the certificate is meant to be used for server authentication, so we can set Extended Key Usage extension to `1.3.6.1.5.5.7.3.1`
x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/HttpCertificateCommand.java
final ZonedDateTime notBefore = ZonedDateTime.now(ZoneOffset.UTC);
            final ZonedDateTime notAfter = notBefore.plus(validity);
            X509Certificate caCert = generateSignedCertificate(dn, null, keyPair, null, null, true, notBefore, notAfter, null);
            printHeader("CA password", terminal);
            terminal.println("We recommend that you protect your CA private key with a strong password.");
            terminal.println("If your key does not have a password (or the password can be easily guessed)");
            terminal.println("then anyone who gets a copy of the key file will be able to generate new certificates");
            terminal.println("and impersonate your Elasticsearch cluster.");
            terminal.println("");
            terminal.println("IT IS IMPORTANT THAT YOU REMEMBER THIS PASSWORD AND KEEP IT SECURE");
            terminal.println("");
            final char[] password = readPassword(terminal, "CA password: ", true);
            return new CertificateTool.CAInfo(caCert, keyPair.getPrivate(), true, password);
        } catch (GeneralSecurityException | CertIOException | OperatorCreationException e) {
            throw new IllegalArgumentException("Cannot generate CA key pair", e);
        }
    }
    /**
     * Read input from the terminal as a {@link Period}.
     * Package protected for testing purposes.
     */
    Period readPeriodInput(Terminal terminal, String prompt, Period defaultValue, int recommendedMinimumDays) {
        Period period = tryReadInput(terminal, prompt, defaultValue, input -> {
            String periodInput = input.replaceAll("[,\\s]", "");
            if (input.charAt(0) != 'P') {
                periodInput = "P" + periodInput;
            }
            try {
                final Period parsed = Period.parse(periodInput);
                final long approxDays = 30 * parsed.toTotalMonths() + parsed.getDays();