Android: Workaround the system certificate issue

Due to removal of local ca-certificates we need to use system's
certificate. However, on Android it is stored in multiple files.
Ladybird doesn't support multiple certificates yet, so we just
concatenate all of them into one big file.
This commit is contained in:
Olekoop 2025-07-10 12:31:21 +02:00 committed by Andrew Kaster
commit f26a898ffc
Notes: github-actions[bot] 2025-07-10 21:46:13 +00:00
3 changed files with 23 additions and 1 deletions

View file

@ -27,7 +27,7 @@ extern ByteString g_default_certificate_path;
ErrorOr<int> service_main(int ipc_socket)
{
RequestServer::g_default_certificate_path = ByteString::formatted("{}/res/ladybird/cacert.pem", WebView::s_ladybird_resource_root);
RequestServer::g_default_certificate_path = ByteString::formatted("{}/cacert.pem", WebView::s_ladybird_resource_root);
Core::EventLoop event_loop;

View file

@ -17,7 +17,12 @@ import java.io.BufferedInputStream
import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.nio.file.Files
import java.util.zip.ZipFile
import kotlin.io.path.Path
import kotlin.io.path.inputStream
import kotlin.io.path.isDirectory
import kotlin.io.path.outputStream
class LadybirdActivity : AppCompatActivity() {
@ -51,6 +56,19 @@ class LadybirdActivity : AppCompatActivity() {
}
}
}
// curl has some issues with the Android's way of storing certificates.
// We need to do this in order to make curl happy.
val certMain = File("$resourceDir/cacert.pem")
certMain.outputStream().use { output ->
Files.walk(Path("/system/etc/security/cacerts")).forEach { certPath ->
if (!certPath.isDirectory()) {
certPath.inputStream().use { input ->
input.copyTo(output)
}
}
}
}
}
val userDir = applicationContext.getExternalFilesDir(null)!!.absolutePath;
initNativeCode(resourceDir, "Ladybird", timerService, userDir)