6 ROOT_CERT_SQL=root-cert.sql
13 echo "`openssl x509 -in $fname -subject -noout -nameopt multiline \
18 function get_common_name()
23 common_name=`get_field $fname commonName`
24 if [[ $common_name == "" ]]; then
25 common_name=`get_field $fname organizationUnitName`
27 if [[ $common_name == "" ]]; then
28 common_name=`get_field $fname organizationName`
30 if [[ $common_name == "" ]]; then
31 common_name=`get_field $fname emailAddress`
34 echo "${common_name:1}" # cut first whitespace
37 function initialize_store()
39 for fname in `find $SYSTEM_SSL_DIR/* | sort`
41 gname=`echo ${fname##*/}`
42 if [[ ! $gname =~ ^[0-9a-z]{8}\.[0-9]$ ]]; then
46 cert=`openssl x509 -in $fname -outform PEM`
47 subject_hash=`openssl x509 -in $fname -subject_hash -noout`
48 subject_hash_old=`openssl x509 -in $fname -subject_hash_old -noout`
49 common_name=`get_common_name $fname`
51 echo "INSERT INTO ssl \
52 (gname, certificate, file_hash, subject_hash, \
53 common_name, enabled, is_root_app_enabled) values \
54 (\"$gname\", \"$cert\", \"$subject_hash\", \"$subject_hash_old\", \
55 \"$common_name\", 1, 1);" >> $ROOT_CERT_SQL
63 cat $ROOT_CERT_SQL | sqlite3 $DB_PATH