From 0570ae1bdcce00ee1fe3057765d18c3717eb377f Mon Sep 17 00:00:00 2001 From: Luke Rasmussen Date: Tue, 10 Jan 2023 16:07:22 -0600 Subject: [PATCH] Closes #304 - support HTTPS on non-standard port Sometimes alternate ports are explicitly defined for HTTPS connections. SSLManager.java should account for the port, if it is provided. --- .../src/main/java/com/aware/utils/SSLManager.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/aware-core/src/main/java/com/aware/utils/SSLManager.java b/aware-core/src/main/java/com/aware/utils/SSLManager.java index be76f8588..725680e8d 100644 --- a/aware-core/src/main/java/com/aware/utils/SSLManager.java +++ b/aware-core/src/main/java/com/aware/utils/SSLManager.java @@ -51,6 +51,7 @@ public static void handleUrl(Context context, String url, boolean block) { if (protocol.equalsIgnoreCase("http")) return; //no need to do anything for http server String hostname = study_uri.getHost(); + int port = study_uri.getPort(); if (study_uri.getQuery() != null) { // If it is in URL parameters, always unconditionally handle it String crt = study_uri.getQueryParameter("crt"); @@ -66,7 +67,7 @@ public static void handleUrl(Context context, String url, boolean block) { if (Aware.DEBUG) Log.d(Aware.TAG, "Certificates: Downloading crt if not present: " + hostname); if (!hasCertificate(context, hostname)) { - downloadCertificate(context, protocol, hostname, true); + downloadCertificate(context, protocol, hostname, port, true); } else { if (Aware.DEBUG) Log.d(Aware.TAG, "Certificates: Already present and key_management=once: " + hostname); @@ -75,7 +76,7 @@ public static void handleUrl(Context context, String url, boolean block) { try { if (!hasCertificate(context, hostname)) { if (Aware.DEBUG) Log.d(Aware.TAG, "Certificates: Downloading for the first time SSL certificate: " + protocol+"://"+hostname); - downloadCertificate(context, protocol, hostname, true); + downloadCertificate(context, protocol, hostname, port, true); } else { //Cached certificate information InputStream localCertificate = getCertificate(context, hostname); @@ -96,6 +97,7 @@ public static class CheckCertificates extends AsyncTask