diff --git a/.gradle/8.0/executionHistory/executionHistory.bin b/.gradle/8.0/executionHistory/executionHistory.bin index 9cfabc2..17b7e13 100644 Binary files a/.gradle/8.0/executionHistory/executionHistory.bin and b/.gradle/8.0/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.0/executionHistory/executionHistory.lock b/.gradle/8.0/executionHistory/executionHistory.lock index 29f73e8..af7d7ce 100644 Binary files a/.gradle/8.0/executionHistory/executionHistory.lock and b/.gradle/8.0/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.0/fileHashes/fileHashes.bin b/.gradle/8.0/fileHashes/fileHashes.bin index df27e59..fe6dc56 100644 Binary files a/.gradle/8.0/fileHashes/fileHashes.bin and b/.gradle/8.0/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.0/fileHashes/fileHashes.lock b/.gradle/8.0/fileHashes/fileHashes.lock index 69b2594..38ae026 100644 Binary files a/.gradle/8.0/fileHashes/fileHashes.lock and b/.gradle/8.0/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.0/fileHashes/resourceHashesCache.bin b/.gradle/8.0/fileHashes/resourceHashesCache.bin index 701eea9..737c9b9 100644 Binary files a/.gradle/8.0/fileHashes/resourceHashesCache.bin and b/.gradle/8.0/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 3075455..9242e00 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 8448912..df22d8c 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/app/src/main/java/com/woodburn/hnsbrowser/WebActivity.java b/app/src/main/java/com/woodburn/hnsbrowser/WebActivity.java index 309c5b9..ba6232e 100644 --- a/app/src/main/java/com/woodburn/hnsbrowser/WebActivity.java +++ b/app/src/main/java/com/woodburn/hnsbrowser/WebActivity.java @@ -14,6 +14,7 @@ import android.webkit.WebViewClient; import android.widget.Toast; import java.net.InetAddress; import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.security.cert.Certificate; import java.util.List; import java.util.concurrent.Executor; @@ -46,6 +47,12 @@ public class WebActivity extends AppCompatActivity { // Set proxy to https://proxy.hnsproxy.au WebSettings webSettings = webView.getSettings(); + webSettings.setJavaScriptEnabled(true); + webSettings.setDomStorageEnabled(true); + webSettings.setDatabaseEnabled(true); + webSettings.setMinimumFontSize(1); + webSettings.setMinimumLogicalFontSize(1); + webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm){ @@ -54,8 +61,34 @@ public class WebActivity extends AppCompatActivity { } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { - handler.proceed(); // Ignore SSL certificate errors - new Thread(new Runnable() { + try { + Certificate certificate = error.getCertificate().getX509Certificate(); + byte[] publicKeyBytes = certificate.getPublicKey().getEncoded(); + MessageDigest sha256Digest = null; + sha256Digest = MessageDigest.getInstance("SHA-256"); + byte[] sha256Hash = sha256Digest.digest(publicKeyBytes); + // Print the hash in hexadecimal format + StringBuilder hexString = new StringBuilder(); + for (byte b : sha256Hash) { + hexString.append(String.format("%02X", b)); + } + // Get TLSA hash via DIG + String siteHash = hexString.toString(); + // Hard coded HNSHosting TLSA + String HNSHostingHash = "7A98E0BC147DA17025C8BF9647A7BF06D7C8F330E99E7BB8828FA9F8E7344B81"; + if (siteHash.equals(HNSHostingHash)) { + handler.proceed(); // Ignore SSL certificate errors + } else { + Toast.makeText(WebActivity.this, "SSL ERROR: TLSA Mismatch", Toast.LENGTH_SHORT).show(); + } + } catch (NoSuchAlgorithmException e) { + Toast.makeText(WebActivity.this, "SSL ERROR: TLSA check error", Toast.LENGTH_SHORT).show(); + } + + + + /*new Thread(new Runnable() { + @Override public void run() { boolean validSSL = false; @@ -71,6 +104,8 @@ public class WebActivity extends AppCompatActivity { } // Get TLSA hash via DIG String siteHash = hexString.toString(); + + // TLSA lookup for HSD String domain = url.replace("https://", ""); if (domain.contains("/")) { domain = domain.substring(0, domain.indexOf("/")); @@ -124,7 +159,7 @@ public class WebActivity extends AppCompatActivity { }); } } - }).start(); + }).start();*/ } }); setProxy();