static @NotNull X509TrustManager createTrustManagerFromCertificates(@NotNull Collection<? extends X509Certificate> certificates) throws Exception {
    KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
    ks.load(null, null);
    for (X509Certificate certificate : certificates) {
      ks.setCertificateEntry(
        certificate.getSubjectX500Principal().toString() + "-" +
        DigestUtilKt.hashToHexString(certificate.getEncoded(), sha3_256()), certificate);
    }

    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    tmf.init(ks);
    List<X509TrustManager> x509TrustManagers = ContainerUtil.filterIsInstance(tmf.getTrustManagers(), X509TrustManager.class);
    if (x509TrustManagers.isEmpty()) {
      throw new IllegalStateException("Unable to create X509TrustManager from keystore: no X509TrustManager instances returned, only " +
                                      Strings.join(Arrays.asList(tmf.getTrustManagers()), " "));
    }
    if (x509TrustManagers.size() > 1) {
      throw new IllegalStateException(
        "Unable to create X509TrustManager from keystore: more than one X509TrustManager instance returned: " +
        Strings.join(x509TrustManagers, " "));
    }

    return x509TrustManagers.get(0);
  }
static @NotNull X509TrustManager createTrustManagerFromCertificates(@NotNull Collection<? extends X509Certificate> certificates)