private static @Nullable Entity readPemEntity(String line, BufferedReader reader) throws IOException {
    if (!line.startsWith(OTHER_BEGIN_MARKER)) {
      return null;
    }
    if (line.startsWith(P1_BEGIN_MARKER)) {
      return new RSAPrivateKey(readPemEntryBytes(reader));
    }
    if (line.startsWith(P8_BEGIN_MARKER)) {
      return new PKCS8PrivateKey(readPemEntryBytes(reader));
    }
    if (line.startsWith(EP8_BEGIN_MARKER)) {
      return new EncryptedPrivateKeyImpl(readPemEntryBytes(reader));
    }
    return new PemCertificate(readPemEntryText(reader, line).toString());
  }
private static @Nullable Entity readPemEntity(String line, BufferedReader reader)