private List<byte[]> pemEntries(String pem) {
            Matcher matcher = pattern.matcher(pem + "\n"); // allow last newline to be omitted in value
            List<byte[]>  entries = new ArrayList<>();
            while (matcher.find()) {
                String base64Str = matcher.group(1).replaceAll("\\s", "");
                entries.add(Base64.getDecoder().decode(base64Str));
            }
            if (entries.isEmpty())
                throw new InvalidConfigurationException("No matching " + name + " entries in PEM file");
            return entries;
        }
Parser to process certificate/private key entries from PEM files
Examples:
  -----BEGIN CERTIFICATE-----
  Base64 cert
  -----END CERTIFICATE-----

  -----BEGIN ENCRYPTED PRIVATE KEY-----
  Base64 private key
  -----END ENCRYPTED PRIVATE KEY-----
  Additional data may be included before headers, so we match all entries within the PEM.
clients/src/main/java/org/apache/kafka/common/security/ssl/DefaultSslEngineFactory.java