pentf
    Preparing search index...

    Function setupTLSClientAuth

    • Modify fetch options for a request authenticated with a client-side TLS certificate.

      Parameters

      • fetchOptions: Object

        The fetch request option object to modify. (init parameter in [[fetch]] above)

      • keyFilename: string

        Name of the private key file in PEM format (e.g. beginning with -----BEGIN RSA PRIVATE KEY-----)

      • certFilename: string

        Name of the certificate file in PEM format (beginning with -----BEGIN CERTIFICATE-----)

      • rejectUnauthorized: boolean = false

        to validate the server's certificate, false (=default) to accept invalid certificates as well.

      Returns Promise<void>

      const init = {method: 'POST', body: '{"something": "secret"}'};
      await setupTLSClientAuth(init, 'key.pem', 'cert.crt');
      const response = await fetch(config, 'https://protected.example.org/', init);
      assert.equal(response.status, 200); // 401 = invalid certificate