private static X509Certificate[] parseCertificates(String pemContent) throws CertificateException {
        String[] pemArray = pemContent.split("-----END CERTIFICATE-----");
        CertificateFactory factory = CertificateFactory.getInstance("X.509");
        X509Certificate[] certs = new X509Certificate[pemArray.length];

        for (int i = 0; i < pemArray.length; i++) {
            String pemPart = pemArray[i];
            byte[] certBytes = Base64.getDecoder().decode(pemPart.replace("-----BEGIN CERTIFICATE-----", "").replaceAll("\n", ""));
            certs[i] = (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(certBytes));
        }
        return certs;
    }
Parse the PEM formatted certificate content into an array of X509 certificates.

@param pemContent The PEM formatted certificate content.
@return An array of X509 certificates.
@throws CertificateException If there is an error parsing the certificates.
server-common/src/main/java/org/apache/kafka/server/metrics/s3stream/S3StreamKafkaMetricsManager.java