From 966680a4d94176e062fee78ca55947b3fe34a8f0 Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Wed, 11 Nov 2015 14:52:10 +0900 Subject: Insert ssl table gname column as a subject hash Change-Id: Ic57f2f8e126b0cc55bc4160348f42270b055a10c Signed-off-by: Kyungwook Tak --- etc/initialize_store_db.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/etc/initialize_store_db.sh b/etc/initialize_store_db.sh index 50b7df3..b726345 100755 --- a/etc/initialize_store_db.sh +++ b/etc/initialize_store_db.sh @@ -5,16 +5,17 @@ DB_PATH=$1 CRT_PATH=$2 ROOT_CERT_SQL=root-cert.sql -MOZILLA_SSL_DIRECTORY=$TZ_SYS_SHARE/ca-certificates/mozilla -TIZEN_SSL_DIRECTORY=$TZ_SYS_SHARE/ca-certificates/tizen +SYSTEM_SSL_DIR=$TZ_SYS_ETC/ssl/certs -function initialize_store_in_dir { - for i in `find $1/* -name '*'` +function initialize_store { + for i in `find $SYSTEM_SSL_DIR/* -name '*'` do - openssl x509 -in $i -outform PEM >> $CRT_PATH -# echo >> $CRT_PATH + gname=`echo $i | cut -f 5 -d '/'` + if [[ ! $gname =~ ^[0-9a-z]{8}\.[0-9]$ ]]; then + continue + fi - gname=`echo $i | cut -f 6 -d '/'` + cert=`openssl x509 -in $i -outform PEM` filehash=`openssl x509 -in $i -hash -noout` subjecthash=`openssl x509 -in $i -subject_hash_old -noout` @@ -32,14 +33,15 @@ function initialize_store_in_dir { commonname=${commonname:1} # cut first whitespace echo "INSERT INTO ssl (gname, certificate, file_hash, subject_hash, common_name, enabled, is_root_app_enabled) values (\"$gname\", \"$cert\", \"$filehash\", \"$subjecthash\", \"$commonname\", 1, 1);" >> $ROOT_CERT_SQL + + openssl x509 -in $i -outform PEM >> $CRT_PATH done } touch $ROOT_CERT_SQL touch $CRT_PATH -initialize_store_in_dir $MOZILLA_SSL_DIRECTORY -initialize_store_in_dir $TIZEN_SSL_DIRECTORY +initialize_store cat $ROOT_CERT_SQL | sqlite3 $DB_PATH rm $ROOT_CERT_SQL -- cgit v1.2.3