       else error:'must be a require()\'able string or a function',arg:arg
 
 
+# export a builder function which tries to read certs, when specified,
+# so this will "fail fast" if there's a problem reading the cert files
 module.exports = (options) ->
 
   # if the certs are provided then try to read them now

  # store provided options in `_options`
  constructor: (@_options) ->

    # TODO:
    #   check for error results from all of these.
    #   set it on _error for the builder function to find and return

  _addOrdering: (chain) ->
    chain.on 'add', markChanged
    chain.on 'remove', markChanged
    chain.on 'start', ensureOrdered
    return chain

    @_serverChain = buildChain()
    @_serverClientChain = buildChain()

  _makeChain: (listeners) ->

    chain = @_addOrdering buildChain()
    chain.add listeners
    return chain

  getClientChain: () ->

    unless @_clientChain?

    return @_clientChain


  # get the actual server chain, build it when it doesn't exist
  getServerChain: () ->

    unless @serverChain?
