for more reliable pem parsing, use the bouncy castle library instead of string replaceAll + b64 decode