code: public static void addTrustedCertificate(String alias, X509Certificate cert, File storeFile, String storePassword) {
          try {
              KeyStore store = openKeyStore(storeFile, storePassword);
              store.setCertificateEntry(alias, cert);
              saveKeyStore(storeFile, store, storePassword);
          } catch (Exception e) {
              throw new RuntimeException("Failed to import certificate into trust store " + storeFile, e);
          }
      }
docs: Imports a certificate into the trust store.
  
  @param alias
  @param cert
  @param storeFile
  @param storePassword