| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ef63af6 commit 53dd1a8
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,6 +127,13 @@ function requestOCSP(self, hello, ctx, cb) { | |||
| 127 | 127 | ||
| 128 | 128 | if (!ctx) | |
| 129 | 129 | ctx = self.server._sharedCreds; | |
| 130 | + | ||
| 131 | + // TLS socket is using a `net.Server` instead of a tls.TLSServer. | ||
| 132 | + // Some TLS properties like `server._sharedCreds` will not be present | ||
| 133 | + if (!ctx) | ||
| 134 | + return cb(null); | ||
| 135 | + | ||
| 136 | + // TODO(indutny): eventually disallow raw `SecureContext` | ||
| 130 | 137 | if (ctx.context) | |
| 131 | 138 | ctx = ctx.context; | |
| 132 | 139 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,53 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Test asynchronous SNI+OCSP on TLSSocket created with `server` set to | ||
| 4 | + // `net.Server` instead of `tls.Server` | ||
| 5 | + | ||
| 6 | + const common = require('../common'); | ||
| 7 | + | ||
| 8 | + if (!common.hasCrypto) { | ||
| 9 | + common.skip('missing crypto'); | ||
| 10 | + return; | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + const assert = require('assert'); | ||
| 14 | + const fs = require('fs'); | ||
| 15 | + const net = require('net'); | ||
| 16 | + const tls = require('tls'); | ||
| 17 | + | ||
| 18 | + const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); | ||
| 19 | + const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); | ||
| 20 | + | ||
| 21 | + const server = net.createServer(common.mustCall((s) => { | ||
| 22 | + const tlsSocket = new tls.TLSSocket(s, { | ||
| 23 | + isServer: true, | ||
| 24 | + server: server, | ||
| 25 | + | ||
| 26 | + secureContext: tls.createSecureContext({ | ||
| 27 | + key: key, | ||
| 28 | + cert: cert | ||
| 29 | + }), | ||
| 30 | + | ||
| 31 | + SNICallback: common.mustCall((hostname, callback) => { | ||
| 32 | + assert.strictEqual(hostname, 'test.test'); | ||
| 33 | + | ||
| 34 | + callback(null, null); | ||
| 35 | + }) | ||
| 36 | + }); | ||
| 37 | + | ||
| 38 | + tlsSocket.on('secure', common.mustCall(() => { | ||
| 39 | + tlsSocket.end(); | ||
| 40 | + server.close(); | ||
| 41 | + })); | ||
| 42 | + })).listen(0, () => { | ||
| 43 | + const opts = { | ||
| 44 | + servername: 'test.test', | ||
| 45 | + port: server.address().port, | ||
| 46 | + rejectUnauthorized: false, | ||
| 47 | + requestOCSP: true | ||
| 48 | + }; | ||
| 49 | + | ||
| 50 | + tls.connect(opts, function() { | ||
| 51 | + this.end(); | ||
| 52 | + }); | ||
| 53 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments