CVE-2021-32700 (published 2021-06-22T20:15Z)

Ballerina is an open source programming language and platform for cloud application programmers. Ballerina versions 1.2.x and SL releases up to alpha 3 have a potential for a supply chain attack via MiTM against users. Http connections did not make use of TLS and certificate checking was ignored. The vulnerability allows an attacker to substitute or modify packages retrieved from BC thus allowing to inject malicious code into ballerina executables. This has been patched in Ballerina 1.2.14 and Ballerina SwanLake alpha4.

Severity: MEDIUM
CVSS v2 base score: 5.8 (AV:N/AC:M/Au:N/C:P/I:P/A:N)
CVSS v3 base score: 7.4, HIGH (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N)

Weakness information:
cwe_id: CWE-306
cwe_name: Missing Authentication for Critical Function
description: The product does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.
extended_description: 
            
            
         
         

Fix information:
repo_url: https://github.com/ballerina-platform/ballerina-lang
commit_details: repo_url: https://github.com/ballerina-platform/ballerina-lang
author: pramodya1994
author_date: 2021-03-16 18:31:13+05:30
msg: Fix central connection
repository: repo_url: https://github.com/ballerina-platform/ballerina-lang
repo_name: ballerina-platform/ballerina-lang
description: The Ballerina Programming Language
repo_language: Ballerina
owner: ballerina-platform
file_changes: filename: Pull.java
change_type: ModificationType.MODIFY
diff: @@ -30,12 +30,12 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.Authenticator;
-import java.net.HttpURLConnection;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import javax.net.ssl.HttpsURLConnection;
 import javax.ws.rs.core.HttpHeaders;
 
 import static org.ballerinalang.cli.module.util.CliModuleConstants.BALLERINA_PLATFORM;
@@ -43,9 +43,8 @@ import static org.ballerinalang.cli.module.util.CliModuleConstants.BAL_LANG_SPEC
 import static org.ballerinalang.cli.module.util.CliModuleConstants.IDENTITY;
 import static org.ballerinalang.cli.module.util.CliModuleConstants.RESOLVED_REQUESTED_URI;
 import static org.ballerinalang.cli.module.util.Utils.convertToUrl;
-import static org.ballerinalang.cli.module.util.Utils.createHttpUrlConnection;
+import static org.ballerinalang.cli.module.util.Utils.createHttpsUrlConnection;
 import static org.ballerinalang.cli.module.util.Utils.getStatusCode;
-import static org.ballerinalang.cli.module.util.Utils.initializeSsl;
 import static org.ballerinalang.cli.module.util.Utils.setRequestMethod;
 
 /**
@@ -84,11 +83,10 @@ public class Pull {
             logFormatter = new BuildLogFormatter();
         }
 
-        HttpURLConnection conn = null;
+        HttpsURLConnection conn = null;
         try {
-            initializeSsl();
-            conn = createHttpUrlConnection(convertToUrl(url + supportedVersionRange), proxyHost, proxyPort,
-                    proxyUsername, proxyPassword);
+            conn = createHttpsUrlConnection(convertToUrl(url + supportedVersionRange), proxyHost, proxyPort,
+                                            proxyUsername, proxyPassword);
 
             conn.setInstanceFollowRedirects(false);
             setRequestMethod(conn, Utils.RequestMethod.GET);
@@ -101,7 +99,7 @@ public class Pull {
             boolean redirect = false;
             // 302 - Module is found
             // Other - Error occurred, json returned with the error message
-            if (getStatusCode(conn) == HttpURLConnection.HTTP_MOVED_TEMP) {
+            if (getStatusCode(conn) == HttpsURLConnection.HTTP_MOVED_TEMP) {
                 redirect = true;
             } else {
                 handleErrorResponse(conn, url, moduleNameWithOrg);
@@ -112,8 +110,8 @@ public class Pull {
                 String newUrl = conn.getHeaderField(HttpHeaders.LOCATION);
                 String contentDisposition = conn.getHeaderField(HttpHeaders.CONTENT_DISPOSITION);
 
-                conn = createHttpUrlConnection(convertToUrl(newUrl), proxyHost, proxyPort, proxyUsername,
-                        proxyPassword);
+                conn = createHttpsUrlConnection(convertToUrl(newUrl), proxyHost, proxyPort, proxyUsername,
+                                                proxyPassword);
                 conn.setRequestProperty(HttpHeaders.CONTENT_DISPOSITION, contentDisposition);
 
                 createBaloInHomeRepo(conn, modulePathInBaloCache, moduleNameWithOrg, isNightlyBuild, newUrl,
@@ -132,14 +130,14 @@ public class Pull {
     /**
      * Create the balo in home repo.
      *
-     * @param conn                  http connection
+     * @param conn                  https connection
      * @param modulePathInBaloCache module path in balo cache, <user.home>.ballerina/balo_cache/<org-name>/<module-name>
      * @param moduleNameWithOrg     module name with org, <org-name>/<module-name>
      * @param isNightlyBuild        is nightly build
      * @param newUrl                new redirect url
      * @param contentDisposition    content disposition header
      */
-    private static void createBaloInHomeRepo(HttpURLConnection conn, String modulePathInBaloCache,
+    private static void createBaloInHomeRepo(HttpsURLConnection conn, String modulePathInBaloCache,
             String moduleNameWithOrg, boolean isNightlyBuild, String newUrl, String contentDisposition) {
         long responseContentLength = conn.getContentLengthLong();
         if (responseContentLength <= 0) {
@@ -170,12 +168,12 @@ public class Pull {
     /**
      * Write balo file to the home repo.
      *
-     * @param conn             http connection
+     * @param conn             https connection
      * @param baloPath         path of the balo file
      * @param fullModuleName   full module name, <org-name>/<module-name>:<module-version>
      * @param resContentLength response content length
      */
-    private static void writeBaloFile(HttpURLConnection conn, Path baloPath, String fullModuleName,
+    private static void writeBaloFile(HttpsURLConnection conn, Path baloPath, String fullModuleName,
             long resContentLength) {
         try (InputStream inputStream = conn.getInputStream();
                 FileOutputStream outputStream = new FileOutputStream(baloPath.toString())) {
@@ -268,11 +266,11 @@ public class Pull {
     /**
      * Handle error response.
      *
-     * @param conn           http connection
+     * @param conn           https connection
      * @param url            remote repository url
      * @param moduleFullName module name with org and version
      */
-    private static void handleErrorResponse(HttpURLConnection conn, String url, String moduleFullName) {
+    private static void handleErrorResponse(HttpsURLConnection conn, String url, String moduleFullName) {
         try (BufferedReader reader = new BufferedReader(
                 new InputStreamReader(conn.getErrorStream(), Charset.defaultCharset()))) {
             StringBuilder result = new StringBuilder();

programming_language: Java
filename: Push.java
change_type: ModificationType.MODIFY
diff: @@ -30,19 +30,18 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.Authenticator;
-import java.net.HttpURLConnection;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 
+import javax.net.ssl.HttpsURLConnection;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 
 import static org.ballerinalang.cli.module.util.CliModuleConstants.PUSH_ORGANIZATION;
 import static org.ballerinalang.cli.module.util.Utils.convertToUrl;
-import static org.ballerinalang.cli.module.util.Utils.createHttpUrlConnection;
+import static org.ballerinalang.cli.module.util.Utils.createHttpsUrlConnection;
 import static org.ballerinalang.cli.module.util.Utils.getStatusCode;
-import static org.ballerinalang.cli.module.util.Utils.initializeSsl;
 import static org.ballerinalang.cli.module.util.Utils.setRequestMethod;
 
 /**
@@ -76,9 +75,8 @@ public class Push {
      */
     public static void execute(String url, String proxyHost, int proxyPort, String proxyUsername, String proxyPassword,
             String accessToken, String orgName, String moduleName, String version, Path baloPath) {
-        initializeSsl();
-        HttpURLConnection conn = createHttpUrlConnection(convertToUrl(url), proxyHost, proxyPort, proxyUsername,
-                proxyPassword);
+        HttpsURLConnection conn = createHttpsUrlConnection(convertToUrl(url), proxyHost, proxyPort, proxyUsername,
+                                                           proxyPassword);
         conn.setInstanceFollowRedirects(false);
         setRequestMethod(conn, Utils.RequestMethod.POST);
 
@@ -115,21 +113,21 @@ public class Push {
     /**
      * Handle the http response.
      *
-     * @param conn       http connection
+     * @param conn       https connection
      * @param orgName    org name
      * @param moduleName module name
      * @param version    module version
      */
-    private static void handleResponse(HttpURLConnection conn, String orgName, String moduleName, String version) {
+    private static void handleResponse(HttpsURLConnection conn, String orgName, String moduleName, String version) {
         try {
             int statusCode = getStatusCode(conn);
             // 200 - Module pushed successfully
             // Other - Error occurred, json returned with the error message
-            if (statusCode == HttpURLConnection.HTTP_OK) {
+            if (statusCode == HttpsURLConnection.HTTP_OK) {
                 outStream.println(orgName + "/" + moduleName + ":" + version + " pushed to central successfully");
-            } else if (statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
+            } else if (statusCode == HttpsURLConnection.HTTP_UNAUTHORIZED) {
                 errStream.println("unauthorized access token for organization: " + orgName);
-            } else if (statusCode == HttpURLConnection.HTTP_BAD_REQUEST) {
+            } else if (statusCode == HttpsURLConnection.HTTP_BAD_REQUEST) {
                 try (BufferedReader reader = new BufferedReader(
                         new InputStreamReader(conn.getErrorStream(), Charset.defaultCharset()))) {
                     StringBuilder result = new StringBuilder();

programming_language: Java
filename: Search.java
change_type: ModificationType.MODIFY
diff: @@ -27,16 +27,16 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.Authenticator;
-import java.net.HttpURLConnection;
 import java.nio.charset.Charset;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import javax.net.ssl.HttpsURLConnection;
+
 import static org.ballerinalang.cli.module.util.Utils.convertToUrl;
-import static org.ballerinalang.cli.module.util.Utils.createHttpUrlConnection;
+import static org.ballerinalang.cli.module.util.Utils.createHttpsUrlConnection;
 import static org.ballerinalang.cli.module.util.Utils.getStatusCode;
-import static org.ballerinalang.cli.module.util.Utils.initializeSsl;
 import static org.ballerinalang.cli.module.util.Utils.setRequestMethod;
 
 /**
@@ -63,9 +63,8 @@ public class Search {
      */
     public static void execute(String url, String proxyHost, int proxyPort, String proxyUsername, String proxyPassword,
             String terminalWidth) {
-        initializeSsl();
-        HttpURLConnection conn = createHttpUrlConnection(convertToUrl(url), proxyHost, proxyPort, proxyUsername,
-                proxyPassword);
+        HttpsURLConnection conn = createHttpsUrlConnection(convertToUrl(url), proxyHost, proxyPort, proxyUsername,
+                                                           proxyPassword);
         conn.setInstanceFollowRedirects(false);
         setRequestMethod(conn, Utils.RequestMethod.GET);
         handleResponse(conn, getStatusCode(conn), terminalWidth);
@@ -75,16 +74,16 @@ public class Search {
     /**
      * Handle http response.
      *
-     * @param conn          http connection
+     * @param conn          https connection
      * @param statusCode    status code of the response
      * @param terminalWidth terminal width of the CLI
      */
-    private static void handleResponse(HttpURLConnection conn, int statusCode, String terminalWidth) {
+    private static void handleResponse(HttpsURLConnection conn, int statusCode, String terminalWidth) {
         try {
             // 200 - modules found
             // Other - Error occurred, json returned with the error message
             MapValue payload;
-            if (statusCode == HttpURLConnection.HTTP_OK) {
+            if (statusCode == HttpsURLConnection.HTTP_OK) {
                 try (BufferedReader reader = new BufferedReader(
                         new InputStreamReader(conn.getInputStream(), Charset.defaultCharset()))) {
                     StringBuilder result = new StringBuilder();

programming_language: Java
filename: TokenUpdater.java
change_type: ModificationType.MODIFY
diff: @@ -26,12 +26,12 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Paths;
 import java.util.Collections;
 
+import javax.net.ssl.HttpsURLConnection;
 import javax.ws.rs.core.HttpHeaders;
 
 import static org.ballerinalang.cli.module.util.CliModuleConstants.SETTINGS_TOML_FILE;
@@ -104,8 +104,8 @@ public class TokenUpdater {
                 String response = "<svg xmlns=\"http://www.w3.org/2000/svg\"/>";
                 httpExchange.getResponseHeaders()
                         .put(HttpHeaders.CONTENT_TYPE, Collections.singletonList("image/svg+xml"));
-                httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK,
-                        response.getBytes(StandardCharsets.UTF_8).length);
+                httpExchange.sendResponseHeaders(HttpsURLConnection.HTTP_OK,
+                                                 response.getBytes(StandardCharsets.UTF_8).length);
                 os = httpExchange.getResponseBody();
                 os.write(response.getBytes(StandardCharsets.UTF_8));
             } catch (IOException e) {

programming_language: Java
filename: Utils.java
change_type: ModificationType.MODIFY
diff: @@ -18,22 +18,14 @@ package org.ballerinalang.cli.module.util;
 
 import java.io.IOException;
 import java.net.Authenticator;
-import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
 import java.net.PasswordAuthentication;
 import java.net.ProtocolException;
 import java.net.Proxy;
 import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 
 import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import static org.ballerinalang.cli.module.util.CliModuleConstants.SSL;
 
 /**
  * Class contains miscellaneous utility methods.
@@ -49,20 +41,6 @@ public class Utils {
         GET, POST
     }
 
-    private static TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
-        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
-            return new java.security.cert.X509Certificate[] {};
-        }
-
-        public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-            //No need to implement.
-        }
-
-        public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-            //No need to implement.
-        }
-    } };
-
     /**
      * Get proxy for http connection.
      *
@@ -103,20 +81,7 @@ public class Utils {
     }
 
     /**
-     * Initialize SSL.
-     */
-    public static void initializeSsl() {
-        try {
-            SSLContext sc = SSLContext.getInstance(SSL);
-            sc.init(null, trustAllCerts, new java.security.SecureRandom());
-            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
-        } catch (NoSuchAlgorithmException | KeyManagementException e) {
-            throw ErrorUtil.createCommandException("initializing SSL failed: " + e.getMessage());
-        }
-    }
-
-    /**
-     * Create http URL connection.
+     * Create https URL connection.
      *
      * @param url           connection URL
      * @param proxyHost     proxy host
@@ -125,15 +90,15 @@ public class Utils {
      * @param proxyPassword proxy password
      * @return http URL connection
      */
-    public static HttpURLConnection createHttpUrlConnection(URL url, String proxyHost, int proxyPort,
+    public static HttpsURLConnection createHttpsUrlConnection(URL url, String proxyHost, int proxyPort,
             String proxyUsername, String proxyPassword) {
         try {
             Proxy proxy = getProxy(proxyHost, proxyPort, proxyUsername, proxyPassword);
             // set proxy if exists.
             if (proxy == null) {
-                return (HttpURLConnection) url.openConnection();
+                return (HttpsURLConnection) url.openConnection();
             } else {
-                return (HttpURLConnection) url.openConnection(proxy);
+                return (HttpsURLConnection) url.openConnection(proxy);
             }
         } catch (IOException e) {
             throw ErrorUtil.createCommandException(e.getMessage());
@@ -143,10 +108,10 @@ public class Utils {
     /**
      * Set request method of the http connection.
      *
-     * @param conn   http connection
+     * @param conn   https connection
      * @param method request method
      */
-    public static void setRequestMethod(HttpURLConnection conn, RequestMethod method) {
+    public static void setRequestMethod(HttpsURLConnection conn, RequestMethod method) {
         try {
             conn.setRequestMethod(getRequestMethodAsString(method));
         } catch (ProtocolException e) {
@@ -168,10 +133,10 @@ public class Utils {
     /**
      * Get status code of http response.
      *
-     * @param conn http connection
+     * @param conn https connection
      * @return status code
      */
-    public static int getStatusCode(HttpURLConnection conn) {
+    public static int getStatusCode(HttpsURLConnection conn) {
         try {
             return conn.getResponseCode();
         } catch (IOException e) {

programming_language: Java
filename: UtilsTest.java
change_type: ModificationType.MODIFY
diff: @@ -22,11 +22,12 @@ import org.ballerinalang.cli.module.util.Utils;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import java.net.HttpURLConnection;
 import java.net.Proxy;
 
+import javax.net.ssl.HttpsURLConnection;
+
 import static org.ballerinalang.cli.module.util.Utils.convertToUrl;
-import static org.ballerinalang.cli.module.util.Utils.createHttpUrlConnection;
+import static org.ballerinalang.cli.module.util.Utils.createHttpsUrlConnection;
 
 /**
  * Unit tests for Utils class.
@@ -50,20 +51,20 @@ public class UtilsTest {
 
     }
 
-    @Test(description = "Test create http URL connection without proxy")
+    @Test(description = "Test create https URL connection without proxy")
     public void testCreateHttpUrlConnection() {
-        HttpURLConnection conn;
+        HttpsURLConnection conn;
         // Test without proxy
-        conn = createHttpUrlConnection(convertToUrl(TEST_URL), "", 0, "", "");
+        conn = createHttpsUrlConnection(convertToUrl(TEST_URL), "", 0, "", "");
         Assert.assertNotNull(conn);
         // Test with the proxy
-        conn = createHttpUrlConnection(convertToUrl(TEST_URL), "http://localhost", 9090, "testUser", "testPassword");
+        conn = createHttpsUrlConnection(convertToUrl(TEST_URL), "http://localhost", 9090, "testUser", "testPassword");
         Assert.assertNotNull(conn);
     }
 
     @Test(description = "Test set request")
     public void testSetRequestMethod() {
-        HttpURLConnection conn = createHttpUrlConnection(convertToUrl(TEST_URL), "", 0, "", "");
+        HttpsURLConnection conn = createHttpsUrlConnection(convertToUrl(TEST_URL), "", 0, "", "");
         Utils.setRequestMethod(conn, Utils.RequestMethod.POST);
         Assert.assertEquals(conn.getRequestMethod(), "POST");
     }

programming_language: Java
filename: URIDryConverter.java
change_type: ModificationType.MODIFY
diff: @@ -31,14 +31,11 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.net.Authenticator;
-import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
 import java.net.PasswordAuthentication;
 import java.net.Proxy;
 import java.net.URI;
 import java.nio.charset.Charset;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -46,9 +43,6 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
 
 /**
  *  Checks if there is a latest version in central if version is not mentioned. If there is then the version of the
@@ -64,20 +58,6 @@ public class URIDryConverter extends URIConverter {
     private PrintStream errStream = System.err;
     private Proxy proxy;
 
-    private static TrustManager[] trustAllCerts = new TrustManager[]{
-            new X509TrustManager() {
-                public java.security.cert.X509Certificate[] getAcceptedIssuers() {
-                    return new java.security.cert.X509Certificate[]{};
-                }
-                public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-                    //No need to implement.
-                }
-                public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-                    //No need to implement.
-                }
-            }
-    };
-
     public URIDryConverter(URI base, Map<PackageID, Manifest> dependencyManifests) {
         this(base, dependencyManifests, false);
     }
@@ -85,14 +65,7 @@ public class URIDryConverter extends URIConverter {
     public URIDryConverter(URI base, Map<PackageID, Manifest> dependencyManifests, boolean isBuild) {
         super(base, dependencyManifests, isBuild);
         this.base = URI.create(base.toString() + "/modules/info/");
-        try {
-            SSLContext sc = SSLContext.getInstance("SSL");
-            sc.init(null, trustAllCerts, new java.security.SecureRandom());
-            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
-            proxy = getProxy();
-        } catch (NoSuchAlgorithmException | KeyManagementException e) {
-            // ignore errors
-        }
+        proxy = getProxy();
     }
 
     public Stream<CompilerInput> finalize(URI remoteURI, PackageID moduleID) {
@@ -101,12 +74,12 @@ public class URIDryConverter extends URIConverter {
             // Ballerina.lock already.
             Matcher matcher = semVerPatchPattern.matcher(moduleID.version.value);
             if ("".equals(moduleID.version.value) || "*".equals(moduleID.version.value) || matcher.matches()) {
-                HttpURLConnection conn;
+                HttpsURLConnection conn;
                 // set proxy if exists.
                 if (null == this.proxy) {
-                    conn = (HttpURLConnection) remoteURI.toURL().openConnection();
+                    conn = (HttpsURLConnection) remoteURI.toURL().openConnection();
                 } else {
-                    conn = (HttpURLConnection) remoteURI.toURL().openConnection(this.proxy);
+                    conn = (HttpsURLConnection) remoteURI.toURL().openConnection(this.proxy);
                 }
                 conn.setInstanceFollowRedirects(false);
                 conn.setRequestMethod("GET");

programming_language: Java
filename: CodeGenerator.java
change_type: ModificationType.MODIFY
diff: @@ -122,7 +122,6 @@ public class CodeGenerator {
         writeGeneratedSources(genFiles, srcPath, implPath, type);
     }
 
-
     /**
      * Generates ballerina source for provided Open API Definition in {@code definitionPath}.
      * Generated source will be written to a ballerina module at {@code outPath}
@@ -130,6 +129,7 @@ public class CodeGenerator {
      *
      * @param executionPath  Command execution path
      * @param definitionPath Input Open Api Definition file path
+     * @param serviceName    service name
      * @param outPath        Destination file path to save generated source files. If not provided
      *                       {@code definitionPath} will be used as the default destination path
      * @throws IOException               when file operations fail

programming_language: Java
filename: PackagingTestCase.java
change_type: ModificationType.MODIFY
diff: @@ -38,7 +38,6 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -47,11 +46,12 @@ import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Map;
 
+import javax.net.ssl.HttpsURLConnection;
+
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.awaitility.Awaitility.given;
 import static org.ballerinalang.cli.module.util.Utils.convertToUrl;
-import static org.ballerinalang.cli.module.util.Utils.createHttpUrlConnection;
-import static org.ballerinalang.cli.module.util.Utils.initializeSsl;
+import static org.ballerinalang.cli.module.util.Utils.createHttpsUrlConnection;
 import static org.ballerinalang.cli.module.util.Utils.setRequestMethod;
 import static org.ballerinalang.test.packaging.ModulePushTestCase.REPO_TO_CENTRAL_SUCCESS_MSG;
 import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BLANG_COMPILED_PKG_BINARY_EXT;
@@ -182,9 +182,8 @@ public class PackagingTestCase extends BaseTest {
 
     @Test(description = "Test pullCount of a package from central", dependsOnMethods = "testPull", enabled = false)
     public void testPullCount() throws IOException {
-        initializeSsl();
         String url = RepoUtils.getRemoteRepoURL() + "/modules/info/" + orgName + "/" + moduleName + "/*/";
-        HttpURLConnection conn = createHttpUrlConnection(convertToUrl(url), "", 0, "", "");
+        HttpsURLConnection conn = createHttpsUrlConnection(convertToUrl(url), "", 0, "", "");
         conn.setInstanceFollowRedirects(false);
         setRequestMethod(conn, Utils.RequestMethod.GET);
 

programming_language: Java