ELastic-CertUtil erro trying to create Certificate-authorities, .crt, .key

Hey guys, i am having issues with generating Ca, crt and key for my nodes specifically using any o the below file and this command :

\Users\YashCyb\Downloads\elasticsearch-8.8.0-windows-x86_64\elasticsearch-8.8.0\bin>.\elasticsearch-certutil cert --ca  --pem --in C:\Users\YashCyb\Downloads\elasticsearch-8.8.0-windows-x86_64\elasticsearch-8.8.0\bin\search-guard
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The 'cert' mode generates X.509 certificate and private keys.
    * By default, this generates a single certificate and key for use
       on a single instance.
    * The '-multiple' option will prompt you to enter details for multiple
       instances and will generate a certificate and key for each one
    * The '-in' option allows for the certificate generation to be automated by describing
       the details of each instance in a YAML file
    * An instance is any piece of the Elastic Stack that requires an SSL certificate.
      Depending on your configuration, Elasticsearch, Logstash, Kibana, and Beats
      may all require a certificate and private key.
    * The minimum required value for each instance is a name. This can simply be the
      hostname, which will be used as the Common Name of the certificate. A full
      distinguished name may also be used.
    * A filename value may be required for each instance. This is necessary when the
      name would result in an invalid file or directory name. The name provided here
      is used as the directory name (within the zip) and the prefix for the key and
      certificate files. The filename is required if you are prompted and the name
      is not displayed in the prompt.
    * IP addresses and DNS names are optional. Multiple values can be specified as a
      comma separated string. If no IP addresses or DNS names are provided, you may
      disable hostname verification in your SSL configuration.

   All certificates generated by this tool will be signed by a certificate authority (CA)
      unless the --self-signed command line option is specified.
      The tool can automatically generate a new CA for you, or you can provide your own with
      the --ca or --ca-cert command line options.

By default the 'cert' mode produces a single PKCS#12 output file which holds:
    * The instance certificate
    * The private key for the instance certificate
    * The CA certificate

If you specify any of the following options:
    * -pem (PEM formatted output)
    * -multiple (generate multiple certificates)
    * -in (generate certificates from an input file)
then the output will be be a zip file containing individual certificate/key files

Enter password for CA (--pem) :
Exception in thread "main" java.nio.file.NoSuchFileException: --pem
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:234)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:379)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:431)
        at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:422)
        at java.base/java.nio.file.Files.newInputStream(Files.java:159)
        at org.elasticsearch.common.ssl.KeyStoreUtil.readKeyStore(KeyStoreUtil.java:71)
        at org.elasticsearch.xpack.core.ssl.CertParsingUtils.readKeyPairsFromKeystore(CertParsingUtils.java:105)
        at org.elasticsearch.xpack.core.ssl.CertParsingUtils.readPkcs12KeyPairs(CertParsingUtils.java:96)
        at org.elasticsearch.xpack.security.cli.CertificateTool$CertificateCommand.lambda$loadPkcs12CA$1(CertificateTool.java:366)
        at org.elasticsearch.xpack.security.cli.CertificateTool.withPassword(CertificateTool.java:1027)
        at org.elasticsearch.xpack.security.cli.CertificateTool$CertificateCommand.loadPkcs12CA(CertificateTool.java:361)
        at org.elasticsearch.xpack.security.cli.CertificateTool$CertificateCommand.getCAInfo(CertificateTool.java:347)
        at org.elasticsearch.xpack.security.cli.CertificateTool$GenerateCertificateCommand.getCAInfo(CertificateTool.java:759)
        at org.elasticsearch.xpack.security.cli.CertificateTool$GenerateCertificateCommand.execute(CertificateTool.java:701)
        at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
        at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:94)
        at org.elasticsearch.xpack.security.cli.CertificateTool.execute(CertificateTool.java:160)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
        at org.elasticsearch.cli.Command.main(Command.java:50)
        at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)

My files are the following , instance.yml together with tlsconfig.yml

Instance,yml :

  GNU nano 7.2                                                                                                /usr/share/elasticsearch/instance.yml *                                                                                                        

- name: "elasticsearch-singlenode"
  dns: [""]

- name: "kibana-singlenode"
  dns: [""]

- name: "logstash-singlenode"
  dns: [""]

tlsconfig.yml :

    validityDays: 3650
    pkPassword: auto
    generatedPasswordLength: 12 
    httpsEnabled: true
    reusetransportCertificatesForHttp: true

        dn: CN=Example COM Inc. Root CA, OU=Example Com Inc. Root CA,O=Example Com Inc.,L=test,C=de 
        pkPassword: none
        keysize: 2048
        file: root-ca.pem

    -name: node
     dn: CN=node-0.example.com , OU=node, O=node,L=test,C=de
     dns: localhost

    - name: admin 
      dn: CN=admin,OU=client,L=test,C=de
      pkPassword: admin 
      admin: true 

In the error message, you can see that you've used --pem rather than -pem and --in instead of -in.

The --ca option requires an argument (the path of a CA file)

From the docs:

[--ca <file_path>]

Because you didn't provide one, the tool assumes that the next argument (--pem) is the path to your CA.

Thank you for the prompt response :

Encountered issues with unzipping the "ca.zip" :

Creating the "ca.zip file" :

C:\Users\YashCyb\Downloads\elasticsearch-8.8.0-windows-x86_64\elasticsearch-8.8.0\bin>.\elasticsearch-certutil ca --out ca.zip
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The 'ca' mode generates a new 'certificate authority'
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in 'cert' mode.

Use the 'ca-dn' option if you wish to configure the 'distinguished name'
of the certificate authority

By default the 'ca' mode produces a single PKCS#12 output file which holds:
    * The CA certificate
    * The CA's private key

If you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private key

Enter password for ca.zip : *******

Compression issues -The ca.zip file was empty

My end goal is to achieve something like this :

C:\Users\YashCyb\Downloads\elasticsearch-8.8.0-windows-x86_64\elasticsearch-8.8.0\bin>.\elasticsearch-certutil cert --ca-cert ca.crt --ca-key ca.key --in instance.yml --out self-signed-elastic-stack.zip

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.