|
| 1 | +if (!process.versions.openssl) { |
| 2 | + console.error('Skipping because node compiled without OpenSSL.'); |
| 3 | + process.exit(0); |
| 4 | +} |
| 5 | + |
| 6 | +var common = require('../common'); |
| 7 | +var assert = require('assert'); |
| 8 | +var tls = require('tls'); |
| 9 | + |
| 10 | +assert.throws(function() { |
| 11 | + tls.createSecureContext({ secureProtocol: 'blargh' }); |
| 12 | +}, /Unknown method/); |
| 13 | + |
| 14 | +assert.throws(function() { |
| 15 | + tls.createSecureContext({ secureProtocol: 'SSLv2_method' }); |
| 16 | +}, /SSLv2 methods disabled/); |
| 17 | + |
| 18 | +assert.throws(function() { |
| 19 | + tls.createSecureContext({ secureProtocol: 'SSLv2_client_method' }); |
| 20 | +}, /SSLv2 methods disabled/); |
| 21 | + |
| 22 | +assert.throws(function() { |
| 23 | + tls.createSecureContext({ secureProtocol: 'SSLv2_server_method' }); |
| 24 | +}, /SSLv2 methods disabled/); |
| 25 | + |
| 26 | +assert.throws(function() { |
| 27 | + tls.createSecureContext({ secureProtocol: 'SSLv3_method' }); |
| 28 | +}, /SSLv3 methods disabled/); |
| 29 | + |
| 30 | +assert.throws(function() { |
| 31 | + tls.createSecureContext({ secureProtocol: 'SSLv3_client_method' }); |
| 32 | +}, /SSLv3 methods disabled/); |
| 33 | + |
| 34 | +assert.throws(function() { |
| 35 | + tls.createSecureContext({ secureProtocol: 'SSLv3_server_method' }); |
| 36 | +}, /SSLv3 methods disabled/); |
| 37 | + |
| 38 | +// Note that SSLv2 and SSLv3 are disallowed but SSLv2_method and friends are |
| 39 | +// still accepted. They are OpenSSL's way of saying that all known protocols |
| 40 | +// are supported unless explicitly disabled (which we do for SSLv2 and SSLv3.) |
| 41 | +tls.createSecureContext({ secureProtocol: 'SSLv23_method' }); |
| 42 | +tls.createSecureContext({ secureProtocol: 'SSLv23_client_method' }); |
| 43 | +tls.createSecureContext({ secureProtocol: 'SSLv23_server_method' }); |
| 44 | +tls.createSecureContext({ secureProtocol: 'TLSv1_method' }); |
| 45 | +tls.createSecureContext({ secureProtocol: 'TLSv1_client_method' }); |
| 46 | +tls.createSecureContext({ secureProtocol: 'TLSv1_server_method' }); |
| 47 | +tls.createSecureContext({ secureProtocol: 'TLSv1_1_method' }); |
| 48 | +tls.createSecureContext({ secureProtocol: 'TLSv1_1_client_method' }); |
| 49 | +tls.createSecureContext({ secureProtocol: 'TLSv1_1_server_method' }); |
| 50 | +tls.createSecureContext({ secureProtocol: 'TLSv1_2_method' }); |
| 51 | +tls.createSecureContext({ secureProtocol: 'TLSv1_2_client_method' }); |
| 52 | +tls.createSecureContext({ secureProtocol: 'TLSv1_2_server_method' }); |
0 commit comments