diff options
author | James M Snell <jasnell@gmail.com> | 2016-03-08 15:31:31 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-03-23 10:34:40 -0700 |
commit | f429fe1b88db3463957058ec8975d3365fc3fefa (patch) | |
tree | 86942a51c941785ed4f472e7ca85e1f01d64d640 /lib/_tls_legacy.js | |
parent | 0b3936b49f06743ea7aa48f4c03c99edf48afe80 (diff) | |
download | android-node-v8-f429fe1b88db3463957058ec8975d3365fc3fefa.tar.gz android-node-v8-f429fe1b88db3463957058ec8975d3365fc3fefa.tar.bz2 android-node-v8-f429fe1b88db3463957058ec8975d3365fc3fefa.zip |
crypto: fail early when loading crypto without openssl
Fail early in require('crypto'), require('tls'),
require('https'), etc when crypto is not available
(rather than depending on an internal try/catch).
Add documentation for detecting when crypto is not available.
PR-URL: https://github.com/nodejs/node/pull/5611
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/_tls_legacy.js')
-rw-r--r-- | lib/_tls_legacy.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index bc293f0417..456679ff0d 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -1,5 +1,7 @@ 'use strict'; +require('internal/util').assertCrypto(exports); + const assert = require('assert'); const EventEmitter = require('events'); const stream = require('stream'); @@ -9,12 +11,7 @@ const common = require('_tls_common'); const debug = util.debuglog('tls-legacy'); const Buffer = require('buffer').Buffer; const Timer = process.binding('timer_wrap').Timer; -var Connection = null; -try { - Connection = process.binding('crypto').Connection; -} catch (e) { - throw new Error('Node.js is not compiled with openssl crypto support'); -} +const Connection = process.binding('crypto').Connection; function SlabBuffer() { this.create(); |