(self, hello, ctx, cb)
| 107 | |
| 108 | |
| 109 | function requestOCSP(self, hello, ctx, cb) { |
| 110 | if (!hello.OCSPRequest || !self.server) |
| 111 | return cb(null); |
| 112 | |
| 113 | if (!ctx) |
| 114 | ctx = self.server._sharedCreds; |
| 115 | if (ctx.context) |
| 116 | ctx = ctx.context; |
| 117 | |
| 118 | if (self.server.listenerCount('OCSPRequest') === 0) { |
| 119 | return cb(null); |
| 120 | } else { |
| 121 | self.server.emit('OCSPRequest', |
| 122 | ctx.getCertificate(), |
| 123 | ctx.getIssuer(), |
| 124 | onOCSP); |
| 125 | } |
| 126 | |
| 127 | var once = false; |
| 128 | function onOCSP(err, response) { |
| 129 | if (once) |
| 130 | return cb(new Error('TLS OCSP callback was called 2 times')); |
| 131 | once = true; |
| 132 | |
| 133 | if (err) |
| 134 | return cb(err); |
| 135 | |
| 136 | if (!self._handle) |
| 137 | return cb(new Error('Socket is closed')); |
| 138 | |
| 139 | if (response) |
| 140 | self._handle.setOCSPResponse(response); |
| 141 | cb(null); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | |
| 146 | function onclienthello(hello) { |
no test coverage detected