How to use the tls function from node-forge

Find comprehensive JavaScript node-forge.tls code examples handpicked from public code repositorys.

350
351
352
353
354
355
356
357
358
359

__Examples__

```js
// create TLS client
var client = forge.tls.createConnection({
  server: false,
  caStore: /* Array of PEM-formatted certs or a CA store object */,
  sessionCache: {},
  // supported cipher suites in order of preference
fork icon5
star icon35
watch icon6

327
328
329
330
331
332
333
334
335
336
caStore: /* Array of PEM-formatted certs or a CA store object */,
sessionCache: {},
// supported cipher suites in order of preference
cipherSuites: [
  forge.tls.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA,
  forge.tls.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA],
virtualHost: 'example.com',
verify: function(connection, verified, depth, certs) {
  if(depth === 0) {
    var cn = certs[0].subject.getField('CN').value;
fork icon1
star icon8
watch icon2

+ 5 other calls in file

244
245
246
247
248
249
250
251
252
253
verify: function(connection, verified, depth, certs) {
  if(depth === 0) {
    var cn = certs[0].subject.getField('CN').value;
    if(cn !== 'example.com') {
      verified = {
        alert: forge.tls.Alert.Description.bad_certificate,
        message: 'Certificate common name does not match hostname.'
      };
    }
  }
fork icon767
star icon0
watch icon0

+ 17 other calls in file