redbird icon indicating copy to clipboard operation
redbird copied to clipboard

ERR_INVALID_ARG_TYPE When Getting Certificate

Open Cerlancism opened this issue 4 years ago • 10 comments

I tried production with false it got https://github.com/OptimalBits/redbird/issues/233, and with true I got this instead.

{
    "level": 50,
    "time": 1590171135449,
    "pid": 3776,
    "hostname": "ubuntu-default",
    "name": "redbird",
    "code": "ERR_INVALID_ARG_TYPE",
    "msg": "Error registering LetsEncrypt certificates",
    "stack": "TypeError [ERR_INVALID_ARG_TYPE]: The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined\n    at writeFile (fs.js:1356:5)\n    at internal/util.js:297:30\n    at new Promise (<anonymous>)\n    at writeFile (internal/util.js:296:12)\n    at Object.stageAsync (/home/user/node-reverse/node_modules/safe-replace/index.js:65:14)\n    at Object.writeFileAsync (/home/user/node-reverse/node_modules/safe-replace/index.js:57:18)\n    at /home/user/node-reverse/node_modules/le-store-certbot/index.js:288:19",
    "type": "Error",
    "v": 1
}

The stack

TypeError [ERR_INVALID_ARG_TYPE]: The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at writeFile (fs.js:1356:5)
    at internal/util.js:297:30
    at new Promise (<anonymous>)
    at writeFile (internal/util.js:296:12)
    at Object.stageAsync (/home/user/node-reverse/node_modules/safe-replace/index.js:65:14)
    at Object.writeFileAsync (/home/user/node-reverse/node_modules/safe-replace/index.js:57:18)
    at /home/user/node-reverse/node_modules/le-store-certbot/index.js:288:19",

My script

const proxy = require('redbird')(
    {
        port: 80, // http port is needed for LetsEncrypt challenge during request / renewal. Also enables automatic http->https redirection for registered https routes.
        letsencrypt:
        {
            path: __dirname + '/certs',
            port: 9999 // LetsEncrypt minimal web server port for handling challenges. Routed 80->9999, no need to open 9999 in firewall. Default 3000 if not defined.,
        },
        ssl:
        {
            http2: true,
            port: 443, // SSL port used to serve registered https routes with LetsEncrypt certificate.
        }
    }
);

const sslOption =
{
    ssl:
    {
        letsencrypt:
        {
            email: "[email protected]",
            production: true
        }
    }
}

proxy.register("cerlancism.ext.io", "http://localhost:8081", sslOption)

Cerlancism avatar May 22 '20 18:05 Cerlancism

I have this line after port: 80, xfwd: true, // http port is needed for LetsEncrypt challenge during request / renewal. Also enables automatic http->https redirection for registered https routes.

Test with this?

Also, I use npm version 10 I think to get this working.

inspiretk avatar May 23 '20 10:05 inspiretk

Can confirm, same issue, xfwd: true doesn't fix the issue

ruslang02 avatar Jun 06 '20 23:06 ruslang02

What node version are you using? I had to use v10 to get it working

What's your firewall? ufw status

inspiretk avatar Jun 07 '20 02:06 inspiretk

I just tested on fresh install ubuntu 18.04. All working normal.

node -v v10.21.0

I know long time ago I used latest node and it failed. Then I had to use v10 to get it working. I forgot what error it was. Maybe test on different version see if it works?

Ubuntu 18.04:

remove node npm

sudo apt remove -y nodejs sudo apt remove -y npm cd /etc/apt/sources.list.d

> and remove any node list if you hav

sudo apt-get update

install node v10.x

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - apt install -y nodejs

installs node and npm

Also check your ports. Just disable firewall for now to test it. I do believe redbird uses port 9999 and also 80, 443.

inspiretk avatar Jun 07 '20 02:06 inspiretk

Thanks! Changing to node 10 using nvm fixes the problem

ruslang02 avatar Jun 07 '20 13:06 ruslang02

UPD: node 12 and node 13 do not have these issues as well

A node 14 specific issue it seems

ruslang02 avatar Jun 07 '20 14:06 ruslang02

Good work. Thanks for sharing info on node 12 and 13 works! Redbird should really update their docs to let people know.

inspiretk avatar Jun 08 '20 01:06 inspiretk

Thanks. Can confirm as I am using Node 14. Tried on Node 10 it's working fine except still getting https://github.com/OptimalBits/redbird/issues/233 when set production: false. I was actually banned for testing this out as I have to use production: true.

Cerlancism avatar Jun 14 '20 06:06 Cerlancism

You should make a new ticket with your details and what you have done and error output

inspiretk avatar Jun 15 '20 08:06 inspiretk

Thank you. Works good in Node 12.18.3 LTS.

roslovets avatar Aug 15 '20 01:08 roslovets