@@ -38,7 +38,7 @@ for PROGRAM in \
38
38
do
39
39
if ! hash " ${PROGRAM} " 2> /dev/null
40
40
then
41
- printf " error: command not found in PATH: %s\n" " ${PROGRAM} " >&2
41
+ printf " [-] error: command not found in PATH: %s\n" " ${PROGRAM} " >&2
42
42
exit 1
43
43
fi
44
44
done
@@ -48,7 +48,7 @@ unset PROGRAM
48
48
export PS4=' +(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
49
49
declare -A CAs=()
50
50
declare -A CERT8_CAs=()
51
- declare -A CERT8_NICKS=()
51
+ # declare -A CERT8_NICKS=()
52
52
# this uses all the available firefox profiles
53
53
INDEX_ALL_CERT8=0
54
54
declare -a BASIC_LIST=(
@@ -92,7 +92,7 @@ function import_cas() {
92
92
93
93
if [ -z " ${FF_HOME} " ]
94
94
then
95
- echo " ${FUNCNAME} (): error: FF_HOME not defined!" 1>&2
95
+ echo " [-] error: FF_HOME not defined!" 1>&2
96
96
return 1
97
97
fi
98
98
@@ -106,14 +106,14 @@ function import_cas() {
106
106
# fi
107
107
if [ ! -f " ${REQUIRED_CA} " ]
108
108
then
109
- echo " error: file \` ${REQUIRED_CA} ' not found!" 1>&2
109
+ echo " [-] error: file \` ${REQUIRED_CA} ' not found!" 1>&2
110
110
continue
111
111
fi
112
112
echo " ${REQUIRED_CA} "
113
113
# certutil requires a "nickname", so we'll use the CN or OU
114
114
# TODO: change this?
115
115
NICKNAME=$( openssl x509 -in " ${REQUIRED_CA} " -noout -subject | sed ' s/^.*\(CN\|OU\)=//' )
116
- cat " ${REQUIRED_CA} " | certutil -A -n " ${NICKNAME} " -t CT,c,c -a -d " ${FF_HOME} "
116
+ certutil -A -n " ${NICKNAME} " -t CT,c,c -a -d " ${FF_HOME} " 0< " ${REQUIRED_CA }"
117
117
118
118
# TEST!!! allow code signing
119
119
# cat "${REQUIRED_CA}" | certutil -A -n "${NICKNAME}" -t CT,c,C -a -d "${FF_HOME}"
@@ -127,7 +127,7 @@ function expand_cert_path() {
127
127
local FILE=" ${1} "
128
128
if [ ! -f " ${FILE} " ]
129
129
then
130
- echo " ${FUNCNAME} (): error: file \` ${FILE} ' not found!" 1>&2
130
+ echo " [-] error: file \` ${FILE} ' not found!" 1>&2
131
131
return 1
132
132
fi
133
133
while [ -h " ${FILE} " ]
@@ -151,17 +151,17 @@ function get_required_cas_list() {
151
151
152
152
if [ -z " ${CP} " ]
153
153
then
154
- echo " error: no CertPatrol path defined!" 1>&2
154
+ echo " [-] error: no CertPatrol path defined!" 1>&2
155
155
return 1
156
156
elif [ ! -f " ${CP} " ]
157
157
then
158
- echo " error: certpatrol DB \` ${CP} ' not found!" 1>&2
158
+ echo " [-] error: certpatrol DB \` ${CP} ' not found!" 1>&2
159
159
return 1
160
160
fi
161
161
162
162
# read all the issuer fingerprints from certificate patrol's DB
163
163
echo " reading issuer fingerprints from certpatrol's DB"
164
- FINGERPRINTS=( $( sqlite3 ${CP} 0<<< " select distinct issuerSha1Fingerprint from certificates where issuerSha1Fingerprint is not '';" ) )
164
+ FINGERPRINTS=( $( sqlite3 " ${CP} " 0<<< " select distinct issuerSha1Fingerprint from certificates where issuerSha1Fingerprint is not '';" ) )
165
165
echo -e " ${# FINGERPRINTS[*]} issuer fingerprints found\n"
166
166
for FINGERPRINT in ${FINGERPRINTS[*]}
167
167
do
@@ -185,7 +185,7 @@ function get_required_cas_list() {
185
185
if [ -z " ${REQUIRED_CA} " ]
186
186
then
187
187
# TODO: check if the cert actually is root CA
188
- echo -e " ${WRN} WARNING ${RST} : no root CA found for this cert -> continue"
188
+ echo -e " [ ${WRN} - ${RST} ]WARNING : no root CA found for this cert -> continue"
189
189
continue
190
190
fi
191
191
echo " root CA found on file system: ${REQUIRED_CA} "
@@ -194,13 +194,13 @@ function get_required_cas_list() {
194
194
# certutil -L -n "${CERT8_CAs[${FINGERPRINT}]}" -a -d "${OLD_FF_HOME}" | openssl verify -CAfile "${REQUIRED_CA}"
195
195
else
196
196
# issuer cert not found
197
- if (( ${ DEBUG} ))
197
+ if (( DEBUG ))
198
198
then
199
- ISSUER_CN=$( sqlite3 ${CP} 0<<< " select distinct issuerCommonName from certificates where issuerSha1Fingerprint is \" ${FINGERPRINT} \" ; " )
199
+ ISSUER_CN=$( sqlite3 " ${CP} " 0<<< " select distinct issuerCommonName from certificates where issuerSha1Fingerprint is \" ${FINGERPRINT} \" ; " )
200
200
echo -e " ${FINGERPRINT} : \0 33[1; 31mnot\0 33[0m found \" ${ISSUER_CN} \" ! " 1>&2
201
201
# print hosts that use this issuer
202
202
echo " sites that use this CA:"
203
- sqlite3 ${CP} 0<<<" select host from certificates where issuerSha1Fingerprint is \" ${FINGERPRINT} \" ; " | sed 's/^/ /'
203
+ sqlite3 " ${CP} " 0<<<" select host from certificates where issuerSha1Fingerprint is \" ${FINGERPRINT} \" ; " | sed 's/^/ /'
204
204
fi
205
205
fi
206
206
if [ -n " ${REQUIRED_CA} " ]
@@ -223,7 +223,7 @@ function print_required_cas_list() {
223
223
echo " ${REQUIRED_CA} "
224
224
if [ ! -f " ${REQUIRED_CA} " ]
225
225
then
226
- echo " WARNING: not found! " 1>&2
226
+ echo " [-] WARNING: not found! " 1>&2
227
227
fi
228
228
done
229
229
@@ -238,7 +238,7 @@ function print_countries() {
238
238
OIFS=${IFS}
239
239
IFS=$'\n'
240
240
# get the " nicknames" , as this is the way certutil handles the certs
241
- NICKNAMES=( $( certutil -L -d " ${FF_HOME} " | fgrep -v " ,," | sed ' 1,4d' | gawk ' NF--' ) )
241
+ NICKNAMES=( $( certutil -L -d " ${FF_HOME} " | grep -F -v " ,," | sed ' 1,4d' | gawk ' NF--' ) )
242
242
IFS=${OIFS}
243
243
for NICKNAME in " ${NICKNAMES[@]} "
244
244
do
@@ -248,7 +248,7 @@ function print_countries() {
248
248
then
249
249
echo " ${COUNTRY# C=} "
250
250
else
251
- echo " warning: country not found for \` ${NICKNAME} ' !" 1>&2
251
+ echo " [-] warning: country not found for \` ${NICKNAME} ' !" 1>&2
252
252
fi
253
253
done | sort | uniq -c
254
254
@@ -265,13 +265,13 @@ function reverse_index() {
265
265
266
266
if [ -z "${FF_HOME}" ]
267
267
then
268
- echo "${FUNCNAME}(): error: FF_HOME not defined!" 1>&2
268
+ echo "[-] error: FF_HOME not defined!" 1>&2
269
269
return 1
270
270
fi
271
271
272
272
OIFS=${IFS}
273
273
IFS=$' \n '
274
- NICKNAMES=( $( certutil -L -d "${FF_HOME}" | sed ' 1,4d' | fgrep -v ' ,,' | gawk ' NF--' ) )
274
+ NICKNAMES=( $( certutil -L -d "${FF_HOME}" | sed ' 1,4d' | grep -F -v ' ,,' | gawk ' NF--' ) )
275
275
IFS=${OIFS}
276
276
277
277
for NICKNAME in "${NICKNAMES[@]}"
@@ -280,7 +280,7 @@ function reverse_index() {
280
280
FP=$( certutil -L -n "${NICKNAME}" -a -d "${FF_HOME}" | openssl x509 -noout -fingerprint -sha1 | sed ' s/^.* Fingerprint= //' )
281
281
if [ -z "${FP}" ]
282
282
then
283
- echo "WARNING: could not get fingerprint for \`${NICKNAME}' ! " 1>&2
283
+ echo "[-] WARNING: could not get fingerprint for \`${NICKNAME}' ! " 1>&2
284
284
fi
285
285
#FPS+=( $( certutil -L -n " ${NICKNAME} " -a -d " ${FF_HOME} " | openssl x509 -noout -fingerprint -sha1 | sed ' s/^.*Fingerprint=//' ) )
286
286
FPS+=( ${FP} )
@@ -294,7 +294,7 @@ function reverse_index() {
294
294
then
295
295
echo " ${CAs[${FP}]} "
296
296
else
297
- echo " WARNING: \` ${NICKNAME} ' not found (fp=${FP})!" 1>&2
297
+ echo " [-] WARNING: \` ${NICKNAME} ' not found (fp=${FP})!" 1>&2
298
298
fi
299
299
done
300
300
@@ -342,13 +342,13 @@ function index_cas() {
342
342
343
343
if [ -z "${OLD_FF_HOME}" ]
344
344
then
345
- echo "${FUNCNAME}(): WARNING: OLD_FF_HOME not defined -> returning" 1>&2
345
+ echo "[-] WARNING: OLD_FF_HOME not defined -> returning" 1>&2
346
346
return 1
347
347
fi
348
348
349
349
# cert8.db
350
350
# use all available firefox profiles
351
- if (( ${ INDEX_ALL_CERT8} ))
351
+ if (( INDEX_ALL_CERT8 ))
352
352
then
353
353
OIFS=${IFS}
354
354
IFS=$' \n '
@@ -374,7 +374,7 @@ function index_cas() {
374
374
then
375
375
#echo " ${NICKNAME} : ${FP} "
376
376
CERT8_CAs[" ${FP} " ]=" ${NICKNAME} "
377
- CERT8_NICKS[" ${NICKNAME} " ]=" ${FP} "
377
+ # CERT8_NICKS[" ${NICKNAME} " ]=" ${FP} "
378
378
fi
379
379
done
380
380
done
440
440
CP=" ${OLD_FF_HOME} /CertPatrol.sqlite"
441
441
;;
442
442
" P" )
443
- if [ -z " ${OPTARG} " -o ! -d " ${OPTARG} " ]
443
+ if [ -z " ${OPTARG} " ] || [ ! -d " ${OPTARG} " ]
444
444
then
445
- echo " error: -P requires an option! " 1>&2
445
+ echo " [-] error: -P requires an option! " 1>&2
446
446
exit 1
447
447
fi
448
448
FF_HOME=" ${OPTARG} "
453
453
" C" )
454
454
if [ ! -d /usr/share/ca-certificates ]
455
455
then
456
- echo " error: directory \` /usr/share/ca-certificates' does not exist!" 1>&2
457
- echo " you might be running RH/CentOS, which has different system for CAs. see https://github.com/pyllyukko/user.js/issues/140" 1>&2
456
+ echo " [-] error: directory \` /usr/share/ca-certificates' does not exist!" 1>&2
457
+ echo " you might be running RH/CentOS, which has different system for CAs. see https://github.com/pyllyukko/user.js/issues/140" 1>&2
458
458
exit 1
459
459
fi
460
460
REQUIRED_CAs=( ${BASIC_LIST[*]/#/\/usr\/share\/ca-certificates\/} )
@@ -481,7 +481,7 @@ case "${ACTION}" in
481
481
"rev") reverse_index ;;
482
482
"renamelib") rename_libnssckbi ;;
483
483
*)
484
- echo "error: no action defined." 1>&2
484
+ echo "[-] error: no action defined." 1>&2
485
485
exit 1
486
486
;;
487
487
esac
0 commit comments