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]: The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView #259

Open
nick-bull opened this issue Jul 28, 2020 · 2 comments

Comments

@nick-bull
Copy link

nick-bull commented Jul 28, 2020

Getting the following errors:

{"level":50,"time":1595942893309,"pid":16805,"hostname":"ip-xxx-xx-xxx-xx","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:1385: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/ubuntu/proxy/node_modules/safe-replace/index.js:65:14)\n    at Object.writeFileAsync (/home/ubuntu/proxy/node_modules/safe-replace/index.js:57:18)\n    at /home/ubuntu/proxy/node_modules/le-store-certbot/index.js:288:19","type":"Error","v":1}
{"level":30,"time":1595942893309,"pid":16805,"hostname":"ip-xxx-xx-xxx-xx","name":"redbird","msg":"Could not get any certs for api.someurl.com","v":1}

from the following configuration:

const redbird = require('redbird');
const proxy = redbird({
  port: 80,
  letsencrypt: {
    path: __dirname + '/certs',
    port: 9999
  },
  ssl: {
    http2: true,
    port: 443,
  },
});

proxy.register('api.someurl.com', 'http://localhost:3002', {
  ssl: {
    letsencrypt: {
      email: 'xxxxxx@xxxxx.com',
      production: true,
    }
  }
});

What is the data argument? Why is it undefined? Am I meant to create the certificates manually? The certs directory exists, and looks as I'd expect for ACME.


node: v14.5.0
npm: 6.14.5
package.json:

{
  "name": "proxy",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "redbird": "^0.10.0"
  }
}

Tested with node 10.22.0, 12.18.3, and latest. No success

@Dotrar
Copy link

Dotrar commented Sep 2, 2020

I had this same issue and did some digging

turns out the error is on line 288 of le-store-certbot.

If I comment out the following lines:

/*   ............ around line 288 ................. */
var privkeyArchive = path.join(archiveDir, 'privkey' + checkpoints + '.pem'); 
//var bundleArchive = path.join(archiveDir, 'bundle' + checkpoints + '.pem'); //no longer used

return mkdirpAsync(archiveDir).then(function () { 
 return PromiseA.all([ 
   sfs.writeFileAsync(certArchive, pems.cert, 'ascii') 
 , sfs.writeFileAsync(chainArchive, pems.chain, 'ascii') 
 , sfs.writeFileAsync(fullchainArchive, [ pems.cert, pems.chain ].join('\n'), 'ascii') 
 , sfs.writeFileAsync(privkeyArchive, pems.privkey, 'ascii') 
//, sfs.writeFileAsync(bundleArchive, pems.bundle, 'ascii') // <-- comment this line
 ]); 
}).then(function () { 
 return mkdirpAsync(liveDir); 
}).then(function () { 

it works as expected.

furthermore I saw that this certbot store is deprecated, but le-store-fs is a drop in replacement.

https://www.npmjs.com/package/le-store-certbot

I would imagine it's just a case that le-store-certbot hasn't been touched in years, and the world of https has changed, and bundles are now a null response, which trips up the certbot-store.

I haven't checked if changing redbird over to le-store-fs will fix the issue, so if you want to check it and put in a pull request I'll let you have the claim to fame

for reference, redbird now registers https for me and is working as expected :)

@vastamaki
Copy link

I faced the exactly same issue, thanks a lot @Dotrar for the fix 🙏 However, I believe that this issue should be fixed...

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

3 participants