@@ -3207,32 +3207,41 @@ $tls_data
32073207# This file is for use by your $used_by_type
32083208<peer-fingerprint>
32093209</peer-fingerprint>" > "$pfp_list_file" || \
3210- pfp_error_msg="Failed to create pfp header!${NL}"
3210+ pfp_error_msg="header Failed !${NL}"
32113211 fi
32123212
32133213 # set new CN and fingerprint
32143214 new_pfp="\
32153215# commonName: $inline_crt_CN
32163216$crt_fingerprint"
32173217
3218- # add new fingerprint to list
3219- {
3220- sed -e /'<\/peer-fingerprint>'/d "$pfp_list_file"
3221- print "${new_pfp}${NL}</peer-fingerprint>"
3222- } > "$pfp_list_tmp" || \
3223- pfp_error_msg="${pfp_error_msg}Failed to update pfp file!${NL}"
3218+ # delete trailing '</peer-fingerprint' line
3219+ if [ -z "$pfp_error_msg" ]; then
3220+ sed -e /'<\/peer-fingerprint>'/d "$pfp_list_file" \
3221+ >> "$pfp_list_tmp" || \
3222+ pfp_error_msg="${pfp_error_msg}sed Failed!${NL}"
3223+ fi
3224+
3225+ # add new fingerprint and trailing '</peer-fingerprint' lines
3226+ if [ -z "$pfp_error_msg" ]; then
3227+ print "${new_pfp}${NL}</peer-fingerprint>" \
3228+ >> "$pfp_list_tmp" || \
3229+ pfp_error_msg="${pfp_error_msg}update Failed!${NL}"
3230+ fi
32243231
32253232 # move tmp-file to list file
3226- mv "$pfp_list_tmp" "$pfp_list_file" || \
3227- pfp_error_msg="${pfp_error_msg}Failed to move pfp temp file${NL}"
3233+ if [ -z "$pfp_error_msg" ]; then
3234+ mv "$pfp_list_tmp" "$pfp_list_file" || \
3235+ pfp_error_msg="${pfp_error_msg}move Failed!${NL}"
3236+ fi
32283237
3229- # user messages
3230- if [ "$pfp_error_msg" ]; then
3231- warn "inline_file() pfp;${NL}${pfp_error_msg}"
3232- else
3238+ # user info
3239+ if [ -z "$pfp_error_msg" ]; then
32333240 notice "\
32343241Updated the '$inline_crt_type' peer-fingerprint list at:
32353242* $pfp_list_file"
3243+ else
3244+ warn "inline_file() pfp;${NL}${pfp_error_msg}"
32363245 fi
32373246 esac
32383247
0 commit comments