{"_id":"starttls","_rev":"26-ff9168b47a987df24240204aaa58aa30","name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","dist-tags":{"latest":"1.0.1"},"versions":{"0.1.0":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.0","main":"index.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repositories":[{"type":"git","url":"https://github.com/mattcg/starttls.git"}],"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.0","dist":{"shasum":"8117a4d1ee97a43ffcdc4ad692580a69b1485ca9","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.0.tgz","integrity":"sha512-ULn7gL40oqCJ5R1DckI57Zl4NDUlp5jjDStSU0xGro8Ro6S/ZOLY4DgknHn7j3Nrns2SJFMI7CVdm/KA2xh3Uw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBA9CKlil4pEaR/QcY7/SSJn/49seRLCcCfaaFUK/UbtAiEAno1cRWpayvT3M2CqKeiZo5w3p5bmVExbzaksq+DRSQU="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.1.1":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.1","main":"index.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repositories":[{"type":"git","url":"https://github.com/mattcg/starttls.git"}],"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.1","dist":{"shasum":"87c8feae040be7c7aa331bdf712ae7af80ffbd04","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.1.tgz","integrity":"sha512-4H1Q0AU+uqemquu7/kU2e68PUmbnA7ZS8459Gja/txJ2xzSrNoE+RQpi4FVrzQD3wzaayk9gow+Ura1bPMlpsA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC8jrxvGqMM/Ymqrgtn7IFejsSxFoVT5xg4FkmHsT/3jAIgA/gOSAsnIDOU5yVvAMVceLDRXeuHVPFFyIO1GhAP88A="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.1.2":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.2","main":"index.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repositories":[{"type":"git","url":"https://github.com/mattcg/starttls.git"}],"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.2","dist":{"shasum":"2aa307a27ac9e0e50d2d66ff1bfb5efa69ad84ef","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.2.tgz","integrity":"sha512-QOaC3V9YBePwoHXq+tBgel0X7uskvKep2bOJryvSgdlwFtFUGFOP+ueFQcIbNqb+RmS9Jcszskw2aAwr0OVlwQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC2MGtT6EpS8IlTqfDb324yLgg3yr2XvyjBb0RzCI0kgAiACNLY8GprTGMHTFugoxWBq069ZJYb7pObn2jU2K6rr6A=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.1.3":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.3","main":"index.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repositories":[{"type":"git","url":"https://github.com/mattcg/starttls.git"}],"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.3","dist":{"shasum":"7685ab60a1157e7f8f4c1fc14be67486ff70299c","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.3.tgz","integrity":"sha512-I4k/sosSAE8ive+ojI75SKKKVN3r+X98FoVrIUHqFSmsM79iqjoFJ6qNnSph2k9SC8MoIuDToGWuCPm4/MLGTQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVAPk72cvIpIlFb4dB9D4FiPq3NKdXJL9GK3z0Q547mwIhAJLmoe9X3H9walhoRO1kMUgqewQpdfGzTt9OR0BLSLBe"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.1.4":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.4","main":"index.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repositories":[{"type":"git","url":"https://github.com/mattcg/starttls.git"}],"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.4","dist":{"shasum":"8e440ac943c6a7b8517c96c8cd3e110d18796463","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.4.tgz","integrity":"sha512-SgCNyofWxfZ5X0U0Lce6OArisYozZ5oGR5uJUm9GYuvu7zLwgkeNFNNInUZwxsnRCzWJkor1lilESIdYL2aziQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCfwqC1F4B5jP1jNp7Ce6YOk9AjC2dGQ9TF9qdK3AmxFQIhALWRtk02P28tU57rYHNd3pYKMulUlsLalYgsmzWUpCh6"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.1.5":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.5","main":"index.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repositories":[{"type":"git","url":"https://github.com/mattcg/starttls.git"}],"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.5","dist":{"shasum":"3bf5d85fc9ea525aee897c332fe4b3b7e0b015ea","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.5.tgz","integrity":"sha512-apCK9uoy7jJJNfUWu/HtjL+6hPoIbPwvKF/4UFTPDts/eIdATRo1Qs5zJfaYDIbfktqTWWA34+JbYXs+8XN2hw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHC8rTVcmMQYEh8i+gbTCKSpsyakR35wwl9CRvzVaK4fAiAtfA/uDP53dlCzOLz330e731kRnA50AeWLedSaiVEe1w=="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.1.6":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.6","main":"lib/starttls.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repositories":[{"type":"git","url":"https://github.com/mattcg/starttls.git"}],"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.6","dist":{"shasum":"6d2fe800160beecfe61c01f17d8e0283e3e9ce3b","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.6.tgz","integrity":"sha512-4vOIVScoRXiteJFPhnTxz5Ki4iu0UZpkOO03TlxJQXKLzu7lfh1L3gu2PFuePIKvjdSccNWbm7PhWDuH88Yu4Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC3aD6ZUwKqmmMqo4fPipEWUs9ABnHhEIPz7SYnLcBIGgIgCW19gPkhnUmK97IZZ9VE8OhVBfoKx7VNgUxJfQkHh4s="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.1.7":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.1.7","main":"lib/starttls.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repository":{"type":"git","url":"https://github.com/mattcg/starttls.git"},"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.1.7","dist":{"shasum":"391e6699f0775faeca44a22952c9392d5ffa2385","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.1.7.tgz","integrity":"sha512-eXgqqgHsZ5Zfr1KxPBpxHr65yLswJY9oPTgLPuaocaBxPyYxVrNEtDXC2l7Bs4oEuumMt7QcK5ciurdEtGAqQg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBssdYnLouI0/h0q89vir2ftb/yDxQQVI/em/O/PaK+4AiBaWswqUmucBuYP6w3L1kd//S21NnDK1digRbgQkGguuA=="}]},"_from":".","_npmVersion":"1.2.21","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.2.0":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.2.0","main":"lib/starttls.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"scripts":{"test":"make test"},"devDependencies":{"mocha":"1.x"},"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repository":{"type":"git","url":"https://github.com/mattcg/starttls.git"},"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.2.0","dist":{"shasum":"5346d6d76cbbc1f4167fd02cd3d0abe726973b45","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.2.0.tgz","integrity":"sha512-L35fyT4YHSAfpAfVQCdliHZ3M6eM5eMLnktlVpixXpX5yrg+6/NhXvNHVMDac9HpzcXbId4F618NF6Qg2rDjnA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBb3dLrdW1YCxAALOd/ZuBYQQ0uRKun4izIVAemimHDmAiBMGbf5Kwoj0Q63WK4n7AUFsLzcvMcCNJQLyQPASkA4Jw=="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"0.2.1":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"0.2.1","main":"lib/starttls.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"scripts":{"test":"make test"},"devDependencies":{"mocha":"1.x"},"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repository":{"type":"git","url":"https://github.com/mattcg/starttls.git"},"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"_id":"starttls@0.2.1","dist":{"shasum":"b98d3e5e778d46f199c843a64f889f0347c6d19a","tarball":"https://registry.npmjs.org/starttls/-/starttls-0.2.1.tgz","integrity":"sha512-yjM5cImFFD4EjFcMDfKBcb69C8DqR/MGjXcNfV9rTbBCcNlyEg5mdxAWosVsMqVRhe6WMjiffw1d/YYyU3iTSQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDnMtFCpoT7rnllf/aeoEHV8MAFZ4THpZZxOa/kTtoyKAiB0sEJpfkFcfQ5ybKaPkF8bfhhjWRdjobl59l5Ovdawtw=="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}]},"1.0.0":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"1.0.0","main":"lib/starttls.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"scripts":{"test":"make test"},"devDependencies":{"mocha":"1.x"},"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repository":{"type":"git","url":"https://github.com/mattcg/starttls.git"},"engines":{"node":"0.x"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"gitHead":"f96056de46fd6bcfa8c2b6d33c1ca0101e2e5fe5","_id":"starttls@1.0.0","_shasum":"f43c899484f25df1252b3228b8eecf04a670c25b","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}],"dist":{"shasum":"f43c899484f25df1252b3228b8eecf04a670c25b","tarball":"https://registry.npmjs.org/starttls/-/starttls-1.0.0.tgz","integrity":"sha512-XQ5kwuNftYA0r1JBk/dCFfC7Lg+qj/hYF+vSB6G5Cp7grca7J1xwwRqs9ik1Sl788vqVE9yqOLhWCTCPGiQPIg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBvS90/O/Yjt+aKmgXfAHEM9Uh0SbtucaWfGLiAqCYZNAiEAw1sLJ1lZJMdPxEtgOLWJ5Z8vMkpe7sAA9VkC7EmSKcQ="}]}},"1.0.1":{"name":"starttls","description":"Upgrade a regular `net.Stream` connection to a secure `tls` connection.","version":"1.0.1","main":"lib/starttls.js","homepage":"https://github.com/mattcg/starttls","implements":["CommonJS/Modules/1.0"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"keywords":["tls","stream","net","upgrade","ssl"],"scripts":{"test":"make test"},"devDependencies":{"mocha":"1.x"},"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"repository":{"type":"git","url":"git+https://github.com/mattcg/starttls.git"},"licenses":[{"type":"MIT","url":"http://opensource.org/licenses/MIT"}],"gitHead":"274a8b4b4bf3e93c082a4047fd0422c6ac4d74ef","_id":"starttls@1.0.1","_shasum":"e6081c25de6b178f5a75f8f271c1487449183b42","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.1","_npmUser":{"name":"mcg","email":"m@m.cg"},"maintainers":[{"name":"mcg","email":"m@m.cg"}],"dist":{"shasum":"e6081c25de6b178f5a75f8f271c1487449183b42","tarball":"https://registry.npmjs.org/starttls/-/starttls-1.0.1.tgz","integrity":"sha512-mfOPDJsq1GSvCyl6qQK5Slj486+6c2E/DJ3vo0TXs4kB+6xFBBuua2ngiudFyjpRYr9BIibsW9wn/5gl4EPaoA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDI+KhpYp92LaK9ghPhQ+wcRbjHoJrCiokn4d/MBOYVywIhALdOSKJPDRdzhO7TAtr0Gwk536bm1fM4HOfEpAsKULUd"}]}}},"readme":"# Start TLS #\n\n[![Build Status](https://travis-ci.org/mattcg/starttls.png?branch=master)](https://travis-ci.org/mattcg/starttls)\n\nUpgrade a regular [`net.Stream`](http://nodejs.org/api/net.html#net_class_net_socket) connection to a secure [`tls`](http://nodejs.org/api/tls.html) connection.\n\nBased on code by [Andris Reinman](https://github.com/andris9/rai/blob/master/lib/starttls.js), itself based on an older version by [Nathan Rajlich](https://gist.github.com/TooTallNate/848444).\n\n## Usage ##\n\nThis library has one method and accepts either an options hash or a prepared socket as the first argument. It returns a [`SecurePair`](http://nodejs.org/api/tls.html#tls_class_securepair).\n\n### starttls(options, [onSecure]), starttls(socket, [onSecure]) ###\n\nThe following options are supported:\n\n- `socket` - if not provided, a socket will be created using [`net.createConnection`](http://nodejs.org/api/net.html#net_net_createconnection_options_connectionlistener)\n- `host` - used to perform automatic certificate identity checking, to guard against MITM attacks\n- `port` - only used to create a socket (along with the `host` option) if `socket` is not provided\n- `pair` - if you want to provide your own [`SecurePair`](http://nodejs.org/api/tls.html#tls_class_securepair) object\n\nThe `onSecure` callback is  optional and receives `null` or an error object as the first argument (see below for error cases). Within the callback context, `this` refers to the same [`SecurePair`](http://nodejs.org/api/tls.html#tls_class_securepair) object returned by `starttls`.\n\n```javascript\nvar net = require('net');\nvar starttls = require('starttls');\nvar options = {\n\tport: 21,\n\thost: example.com\n};\n\nnet.createConnection(options, function() {\n\toptions.socket = this;\n\tstarttls(options, function(err) {\n\t\tif (err) {\n\n\t\t\t// Something bad happened!\n\t\t\treturn;\n\t\t}\n\n\t\tthis.cleartext.write('garbage');\n\t});\n});\n```\n\nYou should always check for an error before writing to the stream to avoid man-in-the-middle attacks. Errors are produced in the following cases:\n\n- the certificate authority authorization check failed or was negative\n- the server identity check was negative\n\nIf you only pass a socket object, server identity checking will not be performed automatically. In that case you should perform the check manually.\n\n```javascript\nstarttls(socket, function(err) {\n\tif (!tls.checkServerIdentity(host, this.cleartext.getPeerCertificate())) {\n\n\t\t// Hostname mismatch!\n\t\t// Report error and end connection...\n\t}\n});\n```\n\n## Example ##\n\nSee [socks5-https-client](https://github.com/mattcg/socks5-https-client) for use-case.\n\n## Tests ##\n\nRun `make test` or `npm test` to run tests.\n\n## License ##\n\nPortions of this code copyright (c) 2012, Andris Reinman and copyright (c) 2011, Nathan Rajlich.\n\nModified and redistributed under an [MIT license](http://mattcg.mit-license.org/).\n","maintainers":[{"name":"mcg","email":"m@m.cg"}],"time":{"modified":"2022-06-26T23:53:49.457Z","created":"2013-03-05T00:56:38.112Z","0.1.0":"2013-03-05T00:56:39.215Z","0.1.1":"2013-03-07T23:18:04.259Z","0.1.2":"2013-03-08T00:56:45.663Z","0.1.3":"2013-03-08T05:27:00.182Z","0.1.4":"2013-03-08T14:44:11.781Z","0.1.5":"2013-03-13T04:48:54.599Z","0.1.6":"2013-03-13T17:03:53.542Z","0.1.7":"2013-05-23T22:09:32.527Z","0.2.0":"2013-08-27T02:59:15.366Z","0.2.1":"2013-08-27T20:11:24.009Z","1.0.0":"2015-02-25T02:13:10.654Z","1.0.1":"2015-10-21T09:48:54.741Z"},"repository":{"type":"git","url":"git+https://github.com/mattcg/starttls.git"},"homepage":"https://github.com/mattcg/starttls","keywords":["tls","stream","net","upgrade","ssl"],"contributors":[{"name":"Nathan Rajlich","email":"nathan@tootallnate.net"},{"name":"Andris Reinman","email":"andris.reinman@gmail.com"},{"name":"Matthew Caruana Galizia","email":"m@m.cg"}],"bugs":{"url":"https://github.com/mattcg/starttls/issues"},"readmeFilename":"README.md"}