This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch force_ci/object_type
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 0971b8fa67fc36c2abb0d52f662f0d2fdf8ad173
Author: LimJiaWenBrenda <[email protected]>
AuthorDate: Fri Nov 7 10:25:38 2025 +0800

    Support SSL-related parameters and interactive password input in 
export/import tools (#16698)
    
    * Add ssl param + Support interactive pw input
    
    * fix spotless
    
    * Changed params processing order: ts > tpw > pw
    
    (cherry picked from commit ababbf337e2e642bf1225d0bb288a08c4768f409)
---
 .../org/apache/iotdb/tool/common/Constants.java    | 12 ++++++
 .../org/apache/iotdb/tool/common/OptionsUtil.java  | 30 +++++++++++++++
 .../apache/iotdb/tool/data/AbstractDataTool.java   | 41 ++++++++++++++++++++-
 .../apache/iotdb/tool/data/ExportDataTable.java    | 10 +++--
 .../org/apache/iotdb/tool/data/ExportDataTree.java | 29 +++++++++------
 .../apache/iotdb/tool/data/ImportDataTable.java    | 10 +++--
 .../org/apache/iotdb/tool/data/ImportDataTree.java | 10 +++--
 .../iotdb/tool/schema/AbstractSchemaTool.java      | 43 ++++++++++++++++++++--
 .../iotdb/tool/schema/ExportSchemaTable.java       | 10 +++--
 .../apache/iotdb/tool/schema/ExportSchemaTree.java | 12 +++++-
 .../iotdb/tool/schema/ImportSchemaTable.java       | 10 +++--
 .../apache/iotdb/tool/schema/ImportSchemaTree.java | 10 +++--
 12 files changed, 190 insertions(+), 37 deletions(-)

diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/Constants.java 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/Constants.java
index bca36d02416..0d4c5f218b7 100644
--- a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/Constants.java
+++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/Constants.java
@@ -56,6 +56,18 @@ public class Constants {
   public static final String USERNAME_DESC = "Username (optional)";
   public static final String USERNAME_DEFAULT_VALUE = "root";
 
+  public static final String USE_SSL_ARGS = "usessl";
+  public static final String USE_SSL_NAME = "use_ssl";
+  public static final String USE_SSL_DESC = "Use SSL statement. (optional)";
+
+  public static final String TRUST_STORE_ARGS = "ts";
+  public static final String TRUST_STORE_NAME = "trust_store";
+  public static final String TRUST_STORE_DESC = "Trust store. (optional)";
+
+  public static final String TRUST_STORE_PWD_ARGS = "tpw";
+  public static final String TRUST_STORE_PWD_NAME = "trust_store_password";
+  public static final String TRUST_STORE_PWD_DESC = "Trust store password. 
(optional)";
+
   public static final String FILE_TYPE_ARGS = "ft";
   public static final String FILE_TYPE_NAME = "file_type";
   public static final String FILE_TYPE_ARGS_NAME = "format";
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/OptionsUtil.java 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/OptionsUtil.java
index 655bee20684..d128a01bcc8 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/OptionsUtil.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/common/OptionsUtil.java
@@ -103,6 +103,36 @@ public class OptionsUtil extends Constants {
             .build();
     options.addOption(opPassword);
 
+    Option opUseSSL =
+        Option.builder(USE_SSL_ARGS)
+            .longOpt(USE_SSL_NAME)
+            .optionalArg(true)
+            .argName(USE_SSL_NAME)
+            .hasArg()
+            .desc(USE_SSL_DESC)
+            .build();
+    options.addOption(opUseSSL);
+
+    Option opTrustStore =
+        Option.builder(TRUST_STORE_ARGS)
+            .longOpt(TRUST_STORE_NAME)
+            .optionalArg(true)
+            .argName(TRUST_STORE_NAME)
+            .hasArg()
+            .desc(TRUST_STORE_DESC)
+            .build();
+    options.addOption(opTrustStore);
+
+    Option opTrustStorePwd =
+        Option.builder(TRUST_STORE_PWD_ARGS)
+            .longOpt(TRUST_STORE_PWD_NAME)
+            .optionalArg(true)
+            .argName(TRUST_STORE_PWD_NAME)
+            .hasArg()
+            .desc(TRUST_STORE_PWD_DESC)
+            .build();
+    options.addOption(opTrustStorePwd);
+
     return options;
   }
 
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/AbstractDataTool.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/AbstractDataTool.java
index 852c6714004..f5f11bc8d51 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/AbstractDataTool.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/AbstractDataTool.java
@@ -19,7 +19,10 @@
 
 package org.apache.iotdb.tool.data;
 
+import org.apache.iotdb.cli.type.ExitType;
+import org.apache.iotdb.cli.utils.CliContext;
 import org.apache.iotdb.cli.utils.IoTPrinter;
+import org.apache.iotdb.cli.utils.JlineUtils;
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant;
 import org.apache.iotdb.commons.utils.PathUtils;
@@ -50,6 +53,7 @@ import org.apache.tsfile.external.commons.lang3.StringUtils;
 import org.apache.tsfile.read.common.Field;
 import org.apache.tsfile.read.common.RowRecord;
 import org.apache.tsfile.utils.Binary;
+import org.jline.reader.LineReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -86,6 +90,9 @@ public abstract class AbstractDataTool {
   protected static String endTime;
   protected static String username;
   protected static String password;
+  protected static Boolean useSsl;
+  protected static String trustStore;
+  protected static String trustStorePwd;
   protected static Boolean aligned;
   protected static String database;
   protected static String startTime;
@@ -142,7 +149,8 @@ public abstract class AbstractDataTool {
     return str;
   }
 
-  protected static void parseBasicParams(CommandLine commandLine) throws 
ArgsErrorException {
+  protected static void parseBasicParams(CommandLine commandLine)
+      throws ArgsErrorException, IOException {
     host =
         checkRequiredArg(
             Constants.HOST_ARGS, Constants.HOST_NAME, commandLine, 
Constants.HOST_DEFAULT_VALUE);
@@ -155,7 +163,36 @@ public abstract class AbstractDataTool {
             Constants.USERNAME_NAME,
             commandLine,
             Constants.USERNAME_DEFAULT_VALUE);
-    password = commandLine.getOptionValue(Constants.PW_ARGS, 
Constants.PW_DEFAULT_VALUE);
+    CliContext cliCtx = new CliContext(System.in, System.out, System.err, 
ExitType.SYSTEM_EXIT);
+    LineReader lineReader = JlineUtils.getLineReader(cliCtx, username, host, 
port);
+    cliCtx.setLineReader(lineReader);
+    String useSslStr = commandLine.getOptionValue(Constants.USE_SSL_ARGS);
+    useSsl = Boolean.parseBoolean(useSslStr);
+    if (useSsl) {
+      String givenTS = commandLine.getOptionValue(Constants.TRUST_STORE_ARGS);
+      if (givenTS != null) {
+        trustStore = givenTS;
+      } else {
+        trustStore = cliCtx.getLineReader().readLine("please input your 
trust_store:", '\0');
+      }
+      String givenTPW = 
commandLine.getOptionValue(Constants.TRUST_STORE_PWD_ARGS);
+      if (givenTPW != null) {
+        trustStorePwd = givenTPW;
+      } else {
+        trustStorePwd = cliCtx.getLineReader().readLine("please input your 
trust_store_pwd:", '\0');
+      }
+    }
+    boolean hasPw = commandLine.hasOption(Constants.PW_ARGS);
+    if (hasPw) {
+      String inputPassword = commandLine.getOptionValue(Constants.PW_ARGS);
+      if (inputPassword != null) {
+        password = inputPassword;
+      } else {
+        password = cliCtx.getLineReader().readLine("please input your 
password:", '\0');
+      }
+    } else {
+      password = Constants.PW_DEFAULT_VALUE;
+    }
   }
 
   protected static void printHelpOptions(
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTable.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTable.java
index 63760001f74..dcf05baa14e 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTable.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTable.java
@@ -63,14 +63,18 @@ public class ExportDataTable extends AbstractExportData {
 
   @Override
   public void init() throws IoTDBConnectionException, 
StatementExecutionException {
-    tableSession =
+    TableSessionBuilder tableSessionBuilder =
         new TableSessionBuilder()
             .nodeUrls(Collections.singletonList(host + ":" + port))
             .username(username)
             .password(password)
             .database(database)
-            .thriftMaxFrameSize(rpcMaxFrameSize)
-            .build();
+            .thriftMaxFrameSize(rpcMaxFrameSize);
+    if (useSsl) {
+      tableSessionBuilder =
+          
tableSessionBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    tableSession = tableSessionBuilder.build();
     SessionDataSet sessionDataSet = tableSession.executeQueryStatement("show 
databases", timeout);
     List<String> databases = new ArrayList<>();
     while (sessionDataSet.hasNext()) {
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTree.java 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTree.java
index 6751215ef0e..beee7f49c92 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTree.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTree.java
@@ -67,18 +67,23 @@ public class ExportDataTree extends AbstractExportData {
 
   @Override
   public void init() throws IoTDBConnectionException, 
StatementExecutionException, TException {
-    session =
-        new Session(
-            host,
-            Integer.parseInt(port),
-            username,
-            password,
-            SessionConfig.DEFAULT_FETCH_SIZE,
-            null,
-            SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY,
-            rpcMaxFrameSize,
-            SessionConfig.DEFAULT_REDIRECTION_MODE,
-            SessionConfig.DEFAULT_VERSION);
+    Session.Builder sessionBuilder =
+        new Session.Builder()
+            .host(host)
+            .port(Integer.parseInt(port))
+            .username(username)
+            .password(password)
+            .fetchSize(SessionConfig.DEFAULT_FETCH_SIZE)
+            .zoneId(null)
+            
.thriftDefaultBufferSize(SessionConfig.DEFAULT_INITIAL_BUFFER_CAPACITY)
+            .thriftMaxFrameSize(rpcMaxFrameSize)
+            .enableRedirection(SessionConfig.DEFAULT_REDIRECTION_MODE)
+            .version(SessionConfig.DEFAULT_VERSION);
+    if (useSsl) {
+      sessionBuilder =
+          
sessionBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    session = sessionBuilder.build();
     session.open(false);
     timestampPrecision = session.getTimestampPrecision();
     if (timeZoneID != null) {
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java
index e5740f12ccb..f6e84362d90 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java
@@ -66,7 +66,7 @@ public class ImportDataTable extends AbstractImportData {
   private static Map<String, ColumnCategory> columnCategory = new HashMap<>();
 
   public void init() throws InterruptedException {
-    sessionPool =
+    TableSessionPoolBuilder tableSessionPoolBuilder =
         new TableSessionPoolBuilder()
             .nodeUrls(Collections.singletonList(host + ":" + port))
             .user(username)
@@ -75,8 +75,12 @@ public class ImportDataTable extends AbstractImportData {
             .enableThriftCompression(false)
             .enableRedirection(false)
             .enableAutoFetch(false)
-            .database(database)
-            .build();
+            .database(database);
+    if (useSsl) {
+      tableSessionPoolBuilder =
+          
tableSessionPoolBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    sessionPool = tableSessionPoolBuilder.build();
     final File file = new File(targetPath);
     if (!file.isFile() && !file.isDirectory()) {
       ioTPrinter.println(String.format("Source file or directory %s does not 
exist", targetPath));
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTree.java 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTree.java
index 687ed554b29..95aa9263142 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTree.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTree.java
@@ -61,7 +61,7 @@ public class ImportDataTree extends AbstractImportData {
 
   public void init()
       throws InterruptedException, IoTDBConnectionException, 
StatementExecutionException {
-    sessionPool =
+    SessionPool.Builder sessionPoolBuilder =
         new SessionPool.Builder()
             .host(host)
             .port(Integer.parseInt(port))
@@ -70,8 +70,12 @@ public class ImportDataTree extends AbstractImportData {
             .maxSize(threadNum + 1)
             .enableIoTDBRpcCompression(false)
             .enableRedirection(false)
-            .enableAutoFetch(false)
-            .build();
+            .enableAutoFetch(false);
+    if (useSsl) {
+      sessionPoolBuilder =
+          
sessionPoolBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    sessionPool = sessionPoolBuilder.build();
     sessionPool.setEnableQueryRedirection(false);
     if (timeZoneID != null) {
       sessionPool.setTimeZone(timeZoneID);
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/AbstractSchemaTool.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/AbstractSchemaTool.java
index eebf6d66ab5..09442bdab87 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/AbstractSchemaTool.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/AbstractSchemaTool.java
@@ -19,7 +19,10 @@
 
 package org.apache.iotdb.tool.schema;
 
+import org.apache.iotdb.cli.type.ExitType;
+import org.apache.iotdb.cli.utils.CliContext;
 import org.apache.iotdb.cli.utils.IoTPrinter;
+import org.apache.iotdb.cli.utils.JlineUtils;
 import org.apache.iotdb.exception.ArgsErrorException;
 import org.apache.iotdb.session.Session;
 import org.apache.iotdb.tool.common.Constants;
@@ -29,6 +32,7 @@ import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVPrinter;
 import org.apache.commons.csv.QuoteMode;
 import org.apache.tsfile.external.commons.lang3.StringUtils;
+import org.jline.reader.LineReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,6 +50,9 @@ public abstract class AbstractSchemaTool {
   protected static String database;
   protected static String username;
   protected static String password;
+  protected static Boolean useSsl;
+  protected static String trustStore;
+  protected static String trustStorePwd;
   protected static Session session;
   protected static String queryPath;
   protected static int threadNum = 8;
@@ -80,7 +87,8 @@ public abstract class AbstractSchemaTool {
     return str;
   }
 
-  protected static void parseBasicParams(CommandLine commandLine) throws 
ArgsErrorException {
+  protected static void parseBasicParams(CommandLine commandLine)
+      throws ArgsErrorException, IOException {
     host =
         checkRequiredArg(
             Constants.HOST_ARGS, Constants.HOST_NAME, commandLine, 
Constants.HOST_DEFAULT_VALUE);
@@ -93,9 +101,36 @@ public abstract class AbstractSchemaTool {
             Constants.USERNAME_NAME,
             commandLine,
             Constants.USERNAME_DEFAULT_VALUE);
-    password =
-        checkRequiredArg(
-            Constants.PW_ARGS, Constants.PW_NAME, commandLine, 
Constants.PW_DEFAULT_VALUE);
+    CliContext cliCtx = new CliContext(System.in, System.out, System.err, 
ExitType.SYSTEM_EXIT);
+    LineReader lineReader = JlineUtils.getLineReader(cliCtx, username, host, 
port);
+    cliCtx.setLineReader(lineReader);
+    String useSslStr = commandLine.getOptionValue(Constants.USE_SSL_ARGS);
+    useSsl = Boolean.parseBoolean(useSslStr);
+    if (useSsl) {
+      String givenTS = commandLine.getOptionValue(Constants.TRUST_STORE_ARGS);
+      if (givenTS != null) {
+        trustStore = givenTS;
+      } else {
+        trustStore = cliCtx.getLineReader().readLine("please input your 
trust_store:", '\0');
+      }
+      String givenTPW = 
commandLine.getOptionValue(Constants.TRUST_STORE_PWD_ARGS);
+      if (givenTPW != null) {
+        trustStorePwd = givenTPW;
+      } else {
+        trustStorePwd = cliCtx.getLineReader().readLine("please input your 
trust_store_pwd:", '\0');
+      }
+    }
+    boolean hasPw = commandLine.hasOption(Constants.PW_ARGS);
+    if (hasPw) {
+      String inputPassword = commandLine.getOptionValue(Constants.PW_ARGS);
+      if (inputPassword != null) {
+        password = inputPassword;
+      } else {
+        password = cliCtx.getLineReader().readLine("please input your 
password:", '\0');
+      }
+    } else {
+      password = Constants.PW_DEFAULT_VALUE;
+    }
   }
 
   /**
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTable.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTable.java
index bf6c77766b2..2ea66f360e1 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTable.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTable.java
@@ -52,7 +52,7 @@ public class ExportSchemaTable extends AbstractExportSchema {
   private static Map<String, String> tableCommentList = new HashMap<>();
 
   public void init() throws InterruptedException {
-    sessionPool =
+    TableSessionPoolBuilder tableSessionPoolBuilder =
         new TableSessionPoolBuilder()
             .nodeUrls(Collections.singletonList(host + ":" + port))
             .user(username)
@@ -61,8 +61,12 @@ public class ExportSchemaTable extends AbstractExportSchema {
             .enableThriftCompression(false)
             .enableRedirection(false)
             .enableAutoFetch(false)
-            .database(database)
-            .build();
+            .database(database);
+    if (useSsl) {
+      tableSessionPoolBuilder =
+          
tableSessionPoolBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    sessionPool = tableSessionPoolBuilder.build();
     checkDatabase();
     try {
       
parseTablesBySelectSchema(String.format(Constants.EXPORT_SCHEMA_TABLES_SELECT, 
database));
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTree.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTree.java
index b047654f57e..c5fbdbc49d1 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTree.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTree.java
@@ -43,7 +43,17 @@ public class ExportSchemaTree extends AbstractExportSchema {
 
   public void init()
       throws InterruptedException, IoTDBConnectionException, 
StatementExecutionException {
-    session = new Session(host, Integer.parseInt(port), username, password);
+    Session.Builder sessionBuilder =
+        new Session.Builder()
+            .host(host)
+            .port(Integer.parseInt(port))
+            .username(username)
+            .password(password);
+    if (useSsl) {
+      sessionBuilder =
+          
sessionBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    session = sessionBuilder.build();
     session.open(false);
   }
 
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTable.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTable.java
index 138c0b946c5..89d9c56ad9f 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTable.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTable.java
@@ -48,7 +48,7 @@ public class ImportSchemaTable extends AbstractImportSchema {
   private static ITableSessionPool sessionPool;
 
   public void init() throws InterruptedException {
-    sessionPool =
+    TableSessionPoolBuilder tableSessionPoolBuilder =
         new TableSessionPoolBuilder()
             .nodeUrls(Collections.singletonList(host + ":" + port))
             .user(username)
@@ -57,8 +57,12 @@ public class ImportSchemaTable extends AbstractImportSchema {
             .enableThriftCompression(false)
             .enableRedirection(false)
             .enableAutoFetch(false)
-            .database(database)
-            .build();
+            .database(database);
+    if (useSsl) {
+      tableSessionPoolBuilder =
+          
tableSessionPoolBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    sessionPool = tableSessionPoolBuilder.build();
     final File file = new File(targetPath);
     if (!file.isFile() && !file.isDirectory()) {
       ioTPrinter.println(String.format("Source file or directory %s does not 
exist", targetPath));
diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java
 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java
index bbeb31513d3..c5edb7d52e9 100644
--- 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java
+++ 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java
@@ -61,7 +61,7 @@ public class ImportSchemaTree extends AbstractImportSchema {
 
   public void init()
       throws InterruptedException, IoTDBConnectionException, 
StatementExecutionException {
-    sessionPool =
+    SessionPool.Builder sessionPoolBuilder =
         new SessionPool.Builder()
             .host(host)
             .port(Integer.parseInt(port))
@@ -70,8 +70,12 @@ public class ImportSchemaTree extends AbstractImportSchema {
             .maxSize(threadNum + 1)
             .enableIoTDBRpcCompression(false)
             .enableRedirection(false)
-            .enableAutoFetch(false)
-            .build();
+            .enableAutoFetch(false);
+    if (useSsl) {
+      sessionPoolBuilder =
+          
sessionPoolBuilder.useSSL(true).trustStore(trustStore).trustStorePwd(trustStorePwd);
+    }
+    sessionPool = sessionPoolBuilder.build();
     sessionPool.setEnableQueryRedirection(false);
     final File file = new File(targetPath);
     if (!file.isFile() && !file.isDirectory()) {

Reply via email to