re-do infer_filetype() to fix numerous bugs
re-do infer_filetype() to fix numerous bugs

  * only check the filename suffix (don't permit the extension to be
    in the middle of the pathname) to avoid nonsensical values for
    pathnames such as "foo.manager/bar.gbr"
  * avoid the confusing additive logic that yielded nonsensical values
    for pathnames such as "foo.gbr.cer"
  * require ".pem" to be after the other suffix
  * use clear logic to make the function's behavior easier to
    understand

rhansen/rpstir,rhansen/rpstir,rhansen/rpstir,rhansen/rpstir,rhansen/rpstir