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

NodeJs tls library rejects the self signed certificates #18527

Closed
achabahe opened this issue Feb 2, 2018 · 1 comment
Closed

NodeJs tls library rejects the self signed certificates #18527

achabahe opened this issue Feb 2, 2018 · 1 comment
Labels
question Issues that look for answers. tls Issues and PRs related to the tls subsystem. wrong repo Issues that should be opened in another repository.

Comments

@achabahe
Copy link

achabahe commented Feb 2, 2018

I have An internal network and the nodes inside that network should have a secured communications so i figured out that i should TLS library ro establish connections between them , i have generated Root certificate , server certificate

when the client want to connect to a certain server here is the code that it uses to connect to the servrer:

const port = 5556;
const hostname = '25.33.180.82';
const tls = require('tls');
const fs = require('fs');
const options = {
  host: hostname,
  port: port,
  ca: [fs.readFileSync('root-ca.pem')],
}
var socket = tls.connect(options, () => {
  console.log('client connected',
              socket.authorized ? 'authorized' : 'unauthorized');
  //            console.log(socket)
  process.stdin.pipe(socket);
  process.stdin.resume();

  //socket.end();
})

.setEncoding('utf8')

.on('data', (data) => {
  console.log(data);
})

.on('end', () => {
  console.log("End connection");
});

Error:
Error: self signed certificate in certificate chain
at Error (native)
at TLSSocket. (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
Details:
I see a lot of people who suggest to set rejectUnauthorized=false in my case, i guess setting rejectUnauthorized to false will stop the error but my connections are 100% prone to MITM atacks , I see that this is a bug in nodejs tls library that it suffers from and i can't find any fix any where (i have google to page 5 of google results that is really deep) i don't know how other people don't talk about it , AM I missing something here! !!!!! please correct me if i am wrong !!

@bnoordhuis
Copy link
Member

Can you move your question to the help repo? Thanks.

@bnoordhuis bnoordhuis added question Issues that look for answers. tls Issues and PRs related to the tls subsystem. wrong repo Issues that should be opened in another repository. labels Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that look for answers. tls Issues and PRs related to the tls subsystem. wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

2 participants