@VisibleForTesting
  static void initTrustStore(Properties consumerProps) {
    Path trustStorePath = getTrustStorePath(consumerProps);
    if (Files.exists(trustStorePath)) {
      deleteFile(trustStorePath);
    }
    LOGGER.info("Initializing the SSL trust store");
    try {
      // Create the trust store path
      createFile(trustStorePath);
    } catch (FileAlreadyExistsException fex) {
      LOGGER.warn("SSL trust store initialization failed as trust store already exists.");
      return;
    } catch (IOException iex) {
      throw new RuntimeException(String.format("Failed to create the trust store path: %s", trustStorePath), iex);
    }

    try {
      String trustStorePassword = consumerProps.getProperty(SSL_TRUSTSTORE_PASSWORD);
      String serverCertificate = consumerProps.getProperty(STREAM_KAFKA_SSL_SERVER_CERTIFICATE);
      String certificateType = consumerProps.getProperty(STREAM_KAFKA_SSL_CERTIFICATE_TYPE, DEFAULT_CERTIFICATE_TYPE);
      String trustStoreType = consumerProps.getProperty(SSL_TRUSTSTORE_TYPE, DEFAULT_TRUSTSTORE_TYPE);
      consumerProps.setProperty(SSL_TRUSTSTORE_TYPE, trustStoreType);

      // Decode the Base64 string
      byte[] certBytes = Base64.getDecoder().decode(serverCertificate);
      InputStream certInputStream = new ByteArrayInputStream(certBytes);

      // Create a Certificate object
      CertificateFactory certificateFactory = CertificateFactory.getInstance(certificateType);
      Certificate certificate = certificateFactory.generateCertificate(certInputStream);

      // Create a TrustStore and load the default TrustStore
      KeyStore trustStore = KeyStore.getInstance(trustStoreType);

      // Initialize the TrustStore
      trustStore.load(null, null);

      // Add the server certificate to the truststore
      trustStore.setCertificateEntry(DEFAULT_SERVER_ALIAS, certificate);

      // Save the keystore to a file
      try (FileOutputStream fos = new FileOutputStream(trustStorePath.toString())) {
        trustStore.store(fos, trustStorePassword.toCharArray());
      }
      LOGGER.info("Initialized the SSL trust store.");
    } catch (Exception ex) {
      throw new RuntimeException("Error initializing the SSL trust store", ex);
    }
  }
@Test
  public void testInitTrustStore()
      throws CertificateException, NoSuchAlgorithmException, OperatorCreationException, NoSuchProviderException,
             IOException, KeyStoreException {
    Properties consumerProps = new Properties();
    setTrustStoreProps(consumerProps);

    // should not throw any exceptions
    KafkaSSLUtils.initTrustStore(consumerProps);
    validateTrustStoreCertificateCount(1);
  }