index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 'use strict';
  2. var WHITELIST = [
  3. 'ETIMEDOUT',
  4. 'ECONNRESET',
  5. 'EADDRINUSE',
  6. 'ESOCKETTIMEDOUT',
  7. 'ECONNREFUSED',
  8. 'EPIPE',
  9. 'EHOSTUNREACH',
  10. 'EAI_AGAIN'
  11. ];
  12. var BLACKLIST = [
  13. 'ENOTFOUND',
  14. 'ENETUNREACH',
  15. // SSL errors from https://github.com/nodejs/node/blob/ed3d8b13ee9a705d89f9e0397d9e96519e7e47ac/src/node_crypto.cc#L1950
  16. 'UNABLE_TO_GET_ISSUER_CERT',
  17. 'UNABLE_TO_GET_CRL',
  18. 'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
  19. 'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
  20. 'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
  21. 'CERT_SIGNATURE_FAILURE',
  22. 'CRL_SIGNATURE_FAILURE',
  23. 'CERT_NOT_YET_VALID',
  24. 'CERT_HAS_EXPIRED',
  25. 'CRL_NOT_YET_VALID',
  26. 'CRL_HAS_EXPIRED',
  27. 'ERROR_IN_CERT_NOT_BEFORE_FIELD',
  28. 'ERROR_IN_CERT_NOT_AFTER_FIELD',
  29. 'ERROR_IN_CRL_LAST_UPDATE_FIELD',
  30. 'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
  31. 'OUT_OF_MEM',
  32. 'DEPTH_ZERO_SELF_SIGNED_CERT',
  33. 'SELF_SIGNED_CERT_IN_CHAIN',
  34. 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
  35. 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  36. 'CERT_CHAIN_TOO_LONG',
  37. 'CERT_REVOKED',
  38. 'INVALID_CA',
  39. 'PATH_LENGTH_EXCEEDED',
  40. 'INVALID_PURPOSE',
  41. 'CERT_UNTRUSTED',
  42. 'CERT_REJECTED'
  43. ];
  44. module.exports = function (err) {
  45. if (!err || !err.code) {
  46. return true;
  47. }
  48. if (WHITELIST.indexOf(err.code) !== -1) {
  49. return true;
  50. }
  51. if (BLACKLIST.indexOf(err.code) !== -1) {
  52. return false;
  53. }
  54. return true;
  55. };