diff --git a/ballerina/tests/utils.bal b/ballerina/tests/utils.bal index e0a93c78..26cab898 100644 --- a/ballerina/tests/utils.bal +++ b/ballerina/tests/utils.bal @@ -18,7 +18,7 @@ import ballerina/sql; import ballerinax/mssql.driver as _; function getMssqlClient(string? database = (), int port = 1433) returns Client|error { - Client dbClient = check new (host, user, password, database, port); + Client dbClient = check new (host, user, password, database, port, options = {secureSocket: {encrypt:false}}); return dbClient; } diff --git a/native/src/main/java/io/ballerina/stdlib/mssql/nativeimpl/ClientProcessorUtils.java b/native/src/main/java/io/ballerina/stdlib/mssql/nativeimpl/ClientProcessorUtils.java index 717e3314..cb73fae6 100644 --- a/native/src/main/java/io/ballerina/stdlib/mssql/nativeimpl/ClientProcessorUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/mssql/nativeimpl/ClientProcessorUtils.java @@ -59,10 +59,10 @@ public static Object createClient(BObject client, BMap clientCo } BMap options = clientConfig.getMapValue(Constants.ClientConfiguration.OPTIONS); String datasourceName = Constants.MSSQL_DATASOURCE_NAME; - BMap properties = Utils.generateOptionsMap(options);; + BMap properties = null; Properties poolProperties = null; if (options != null) { - // properties = Utils.generateOptionsMap(options); + properties = Utils.generateOptionsMap(options); Object queryTimeout = properties.get(Constants.DatabaseProps.QUERY_TIMEOUT); if (queryTimeout != null) { poolProperties = new Properties(); diff --git a/native/src/main/java/io/ballerina/stdlib/mssql/utils/Utils.java b/native/src/main/java/io/ballerina/stdlib/mssql/utils/Utils.java index aaf90ebc..79a3ea7d 100644 --- a/native/src/main/java/io/ballerina/stdlib/mssql/utils/Utils.java +++ b/native/src/main/java/io/ballerina/stdlib/mssql/utils/Utils.java @@ -31,10 +31,9 @@ public class Utils { public static BMap generateOptionsMap(BMap mssqlOptions) { - BMap options = ValueCreator.createMapValue(); - options.put(Constants.DatabaseProps.ENCRYPT, false); if (mssqlOptions != null) { + BMap options = ValueCreator.createMapValue(); addSSLOptions(mssqlOptions.getMapValue(Constants.Options.SECURE_SOCKET), options); long queryTimeout = getTimeout(mssqlOptions.get(Constants.Options.QUERY_TIMEOUT_SECONDS)); @@ -52,8 +51,9 @@ public static BMap generateOptionsMap(BMap mssqlOptions) { options.put(Constants.DatabaseProps.LOGIN_TIMEOUT, loginTimeout); } + return options; } - return options; + return null; } private static int getBooleanValue(Object value) { @@ -80,8 +80,8 @@ private static void addSSLOptions(BMap sslConfig, BMap options) if (sslConfig != null) { int encrypt = getBooleanValue(sslConfig.get(Constants.SSLConfig.ENCRYPT)); - if (encrypt == 1) { - options.put(Constants.DatabaseProps.ENCRYPT, true); + if (encrypt == 0) { + options.put(Constants.DatabaseProps.ENCRYPT, false); } int trustServerCertificate = getBooleanValue(sslConfig.get(Constants.SSLConfig.TRUST_SERVER_CERTIFICATE));