more careful pem parsing