isSSLError.js 559 B

12345678910111213141516
  1. 'use strict';
  2. const getConstructorName = require('../getConstructorName');
  3. const nonSSLMessage = 'Client network socket disconnected before secure TLS ' +
  4. 'connection was established';
  5. module.exports = function isSSLError(topologyDescription) {
  6. if (getConstructorName(topologyDescription) !== 'TopologyDescription') {
  7. return false;
  8. }
  9. const descriptions = Array.from(topologyDescription.servers.values());
  10. return descriptions.length > 0 &&
  11. descriptions.every(descr => descr.error && descr.error.message.indexOf(nonSSLMessage) !== -1);
  12. };