code: function(callback) {
          if (res.session && res.session.cert) {
            if (res.parsedHeader.payload.mode === 'handshake') {
              if (my.config.crypter.verifyCertificate(res.session.cert)) {
                callback(null);
              } else {
                callback('unknown certificate');
              }
            } else {
              callback(null);
            }
          } else {
            callback('wrong session');
          }
        }
docs: verify certificate authenticity