Skip to content

Commit

Permalink
Revert to MbedTLS 2.x on iOS
Browse files Browse the repository at this point in the history
Before this change it used MbedTLS version 3.x. But with this version, the iOS app could not securely connecto to Bibledit Cloud.

After this change, it was reverted to using MbedTLS version 2.x.
This version can make a secure connection to Bibledit Cloud.

bibledit/cloud#944
  • Loading branch information
teusbenschop committed Aug 8, 2024
1 parent bb4ba85 commit 69d48b4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
56 changes: 32 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function clean
}


# Build libbibledit for one iOS architecure.
# This script runs on OS X.
# Build libbibledit for one iOS architecture.
# This script runs on macOS.
function compile
{

Expand All @@ -31,7 +31,7 @@ SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/$PLATFORM.platform/
if [ $? -ne 0 ]; then exit; fi
TOOLDIR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
if [ $? -ne 0 ]; then exit; fi
COMPILEFLAGS="-Wall -Wextra -pedantic -g -O2 -c -I.."
COMPILEFLAGS="-Wall -g -O2 -c -I.."
if [ $? -ne 0 ]; then exit; fi

pushd webroot
Expand All @@ -45,7 +45,8 @@ if [ $? -ne 0 ]; then exit; fi
# * Remove tabs.
# * Remove new lines.
# * Remove backslashes.
sed -n "/libbibledit_a_SOURCES/,/bin_PROGRAMS/p" Makefile.am | tail -n +2 | sed '$d' | strings | sed 's/\\//g' > sources.txt
# * Remove the mbedtls sources.
sed -n "/libbibledit_a_SOURCES/,/bin_PROGRAMS/p" Makefile.am | tail -n +2 | sed '$d' | strings | sed 's/\\//g' | sed '/mbedtls/d' > sources.txt
if [ $? -ne 0 ]; then exit; fi

# Save the names of the C++ sources to file and load them.
Expand All @@ -59,6 +60,8 @@ if [ $? -ne 0 ]; then exit; fi
# Save the name of the C sources to file and load them.
cat sources.txt | sed '/.cpp/d' | sed '/.cxx/d' > cfiles.txt
if [ $? -ne 0 ]; then exit; fi
ls mbedtls/*.c >> cfiles.txt
if [ $? -ne 0 ]; then exit; fi
CFILES=(`cat cfiles.txt`)
if [ $? -ne 0 ]; then exit; fi

Expand Down Expand Up @@ -173,7 +176,7 @@ if [ $? -ne 0 ]; then exit; fi
popd
if [ $? -ne 0 ]; then exit; fi

# Sychronizes the libbibledit data files in the source tree to iOS and cleans them up.
echo Sychronize the libbibledit data files in the source tree to iOS and clean them up.
rsync -a --delete ../cloud/ webroot
if [ $? -ne 0 ]; then exit; fi
pushd webroot
Expand Down Expand Up @@ -202,28 +205,33 @@ if [ $? -ne 0 ]; then exit; fi

pushd webroot
if [ $? -ne 0 ]; then exit; fi
# Configure Bibledit in client mode,
# Run only only one parallel task so the interface is more responsive.
# Enable the single-tab browser.
echo Configure Bibledit in client mode
echo Run only one parallel task so the interface is more responsive
echo Enable the single-tab browser
./configure --enable-ios
if [ $? -ne 0 ]; then exit; fi
# No longer set the network port manually.
# echo 8765 > config/network-port
# if [ $? -ne 0 ]; then exit; fi
# Update the Makefile.
sed -i.bak '/SWORD_CFLAGS =/d' Makefile
if [ $? -ne 0 ]; then exit; fi
sed -i.bak '/SWORD_LIBS =/d' Makefile
if [ $? -ne 0 ]; then exit; fi
sed -i.bak '/ICU_CFLAGS =/d' Makefile
if [ $? != 0 ]; then exit; fi
sed -i.bak '/ICU_LIBS =/d' Makefile
if [ $? != 0 ]; then exit; fi
sed -i.bak '/XML2_CFLAGS =/d' Makefile
if [ $? != 0 ]; then exit; fi
sed -i.bak '/XML2_LIBS =/d' Makefile
if [ $? != 0 ]; then exit; fi
# Update the configuration: No external SWORD / ICU / UTF8PROC / PUGIXML libraries.
echo Switch to MbedTLS 2.x
rm -rf mbedtls
if [ $? -ne 0 ]; then exit; fi
mv mbedtls2 mbedtls
if [ $? -ne 0 ]; then exit; fi
#echo Update the Makefile
#sed -i.bak '/SWORD_CFLAGS =/d' Makefile
#if [ $? -ne 0 ]; then exit; fi
#sed -i.bak '/SWORD_LIBS =/d' Makefile
#if [ $? -ne 0 ]; then exit; fi
#sed -i.bak '/ICU_CFLAGS =/d' Makefile
#if [ $? != 0 ]; then exit; fi
#sed -i.bak '/ICU_LIBS =/d' Makefile
#if [ $? != 0 ]; then exit; fi
#sed -i.bak '/XML2_CFLAGS =/d' Makefile
#if [ $? != 0 ]; then exit; fi
#sed -i.bak '/XML2_LIBS =/d' Makefile
#if [ $? != 0 ]; then exit; fi
echo Update the configuration: No external SWORD / ICU / UTF8PROC / PUGIXML libraries.
sed -i.bak '/HAVE_SWORD/d' config.h
if [ $? -ne 0 ]; then exit; fi
sed -i.bak '/HAVE_ICU/d' config.h
Expand All @@ -232,10 +240,10 @@ sed -i.bak '/HAVE_UTF8PROC/d' config.h
if [ $? != 0 ]; then exit; fi
sed -i.bak '/HAVE_PUGIXML/d' config.h
if [ $? != 0 ]; then exit; fi
# The embedded web view cannot upload files.
echo The embedded web view cannot upload files.
sed -i.bak '/CONFIG_ENABLE_FILE_UPLOAD/d' config/config.h
if [ $? -ne 0 ]; then exit; fi
# Done.
echo Done.
popd
if [ $? -ne 0 ]; then exit; fi

Expand Down
4 changes: 4 additions & 0 deletions develop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Libraries

The Bibledit library depends on libsqlite3, libz, libc++ Security.framework CFNetwork.framework. The iOS SDK with Xcode includes these libraries. Link against all of these libraries in the project settings, the Build Phases.

In 2024 the app was built with library MbedTLS 3.x but it could not securely connect
to Bibledit Cloud then.
Therefore it was built with MbedTLS 2.x, and then it works well.

Building
========

Expand Down

0 comments on commit 69d48b4

Please sign in to comment.