code: function normalizeDN (dn) {
    if (!dn || typeof dn !== 'string') { return null }
    var normalizedDN = ''
    // Take advantage of replace() to grab the matched segments of the DN. If what
    // is left over contains unexpected characters, we assume the original DN was
    // malformed.
    var extra = dn.replace(dnPartRegex, function (match) {
      normalizedDN += match.toLowerCase() + ','
      return ''
    })
    if (!normalizedDN) { return null }
    if (badExtra.test(extra)) { return null }
    return normalizedDN.substr(0, normalizedDN.length - 1)
  }
docs: Normalizes distinguished names, removing any extra whitespace, lowercasing
  the DN, and running some basic validation checks.
  
  If the DN is found to be malformed, will return null.