Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_INVALID_ARG_TYPE When Getting Certificate #254

Open
Cerlancism opened this issue May 22, 2020 · 10 comments
Open

ERR_INVALID_ARG_TYPE When Getting Certificate #254

Cerlancism opened this issue May 22, 2020 · 10 comments

Comments

@Cerlancism
Copy link

Cerlancism commented May 22, 2020

I tried production with false it got #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)
@inspiretk
Copy link

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.

@ruslang02
Copy link

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

@inspiretk
Copy link

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

What's your firewall? ufw status

@inspiretk
Copy link

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.

@ruslang02
Copy link

Thanks! Changing to node 10 using nvm fixes the problem

@ruslang02
Copy link

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

A node 14 specific issue it seems

@inspiretk
Copy link

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

@Cerlancism
Copy link
Author

Cerlancism commented Jun 14, 2020

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

@inspiretk
Copy link

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

@roslovets
Copy link

Thank you. Works good in Node 12.18.3 LTS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants