private static @NotNull Pair<PrivateKey, List<X509Certificate>> loadPrivateKeyAndCerts(
    @NotNull List<? extends SslEntityReader.Entity> entities, @NotNull String filePath, char[] password)
    throws IOException {
    PrivateKey key = null;
    List<X509Certificate> certs = new ArrayList<>();
    for (SslEntityReader.Entity entity : entities) {
      if (entity instanceof SslEntityReader.EncryptedPrivateKeyEntity) {
        key = ((SslEntityReader.EncryptedPrivateKeyEntity)entity).get(password);
      }
      else if (entity instanceof SslEntityReader.UnencryptedPrivateKeyEntity) {
        key = ((SslEntityReader.UnencryptedPrivateKeyEntity)entity).get();
      }
      else if (entity instanceof SslEntityReader.CertificateEntity) {
        certs.add(((SslEntityReader.CertificateEntity)entity).get());
      }
    }
    if (key == null) {
      throw new IOException("Failed to find key in file " + filePath);
    }
    return Pair.create(key, certs.isEmpty() ? null : certs);
  }
private static @NotNull Pair<PrivateKey, List<X509Certificate>> loadPrivateKeyAndCerts(
    @NotNull List<? extends SslEntityReader.Entity> entities, @NotNull String filePath, char[] password)