Skip to content

Instantly share code, notes, and snippets.

@dcmwong
Last active May 21, 2021 09:03
Show Gist options
  • Save dcmwong/b4175e2f5aca007a0aa6ea405e05b56d to your computer and use it in GitHub Desktop.
Save dcmwong/b4175e2f5aca007a0aa6ea405e05b56d to your computer and use it in GitHub Desktop.
simple send message to tls server
import * as fs from 'fs'
import * as tls from 'tls'
var conn = tls.connect(1234, 'localhost', {}, function () {
if (conn.authorized) {
console.log('Connection authorized by a Certificate Authority.')
conn.write('hello from the client')
} else {
console.log('Connection not authorized: ' + conn.authorizationError)
}
})
conn.on('data', function (data) {
console.log(data.toString())
conn.end()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment