Fixed portability issues, see hannob/hpkp#3
Fixed extension stripping (wrong order).