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

TLS localAddress bind not working #1728

Closed
0x4139 opened this issue May 18, 2015 · 2 comments
Closed

TLS localAddress bind not working #1728

0x4139 opened this issue May 18, 2015 · 2 comments
Labels
tls Issues and PRs related to the tls subsystem.

Comments

@0x4139
Copy link

0x4139 commented May 18, 2015

i have a net.Socket object and an TLS connection object. I have multiple ips on my machine, how can i bind on one of them by choice, here's what i'ved tried:

  • creating the socket with localAddress option - not working.
  • net.connect with localAddress option (seems that tis tries to make the connection again so it's not working)
  • net.createConnection, same story.
@mscdex mscdex added the tls Issues and PRs related to the tls subsystem. label May 18, 2015
@mscdex
Copy link
Contributor

mscdex commented May 18, 2015

If you have a net.Socket that hasn't started connecting yet that you want to upgrade to TLS, you should be able to do:

var cleartext = tls.connect({ socket: socket }, function() {
  console.log('TLS negotatiated!');
});
socket.connect({
  host: 'example.org',
  port: 1337,
  localAddress: '192.168.100.105'
});

If you don't need to explicitly create a net.Socket, you can pass localAddress to tls.connect() like this:

var socket = tls.connect({
  host: 'example.org',
  port: 1337,
  localAddress: '192.168.100.105'
}, function() {
  console.log('TLS negotiated!');
});

@evanlucas
Copy link
Contributor

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants