forked from samsung-ads-grave-yard/papercert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpapercert.sh
More file actions
executable file
·38 lines (29 loc) · 1.16 KB
/
papercert.sh
File metadata and controls
executable file
·38 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
split -b 128 - key- < "$1"
split -b 128 - cert- < "$2"
function make_pages () {
mkdir -vp "raw_$1"
mkdir -vp "png_$1"
mv -v "${1}"-* "raw_${1}/."
for f in raw_$1/$1-*; do
dmtxwrite -ea -o "png_$1/$(basename "${f}").png" "${f}"
done
files=$(find "png_$1" -iname "$1-*.png" | wc -l)
pages=$((files / 35))
if [ $((files % 35)) -gt 0 ]; then
pages=$((pages + 1))
fi
page_range=$(seq 1 1 "${pages}")
for n in "${page_range[@]}"; do
mkdir -v "png_$1/p${n}"
find "png_$1" -iname "$1-*.png" | head -35 | xargs -I {} mv -v {} "png_$1/p${n}/."
montage -verbose -label '%f' -font Helvetica -pointsize 10 -background '#FFFFFF' -fill 'black' -define jpeg:size=240x240 -geometry 240x240+2+2 -tile 5x7 "png_$1/p${n}/$1-*.png" "$1-p${n}.png"
done
}
for t in {key,cert}; do
make_pages ${t}
done
openssl x509 -in "$2" -text -noout -certopt no_pubkey,no_sigdump \
| convert -background white -size 612x792 -font DejaVu-Sans-Mono \
-pointsize 12 -gravity northwest -border 24 label:@- title.pdf
convert "title.pdf" "key-p*.png" "cert-p*.png" -quality 100 combined.pdf