| 1 |
/testing/guestbin/swan-prep --nokeys |
| 2 |
|
| 3 |
# Generate three CA+cert pairs. |
| 4 |
# |
| 5 |
# new-ca+new-cert: a sane CA and a sane peer certificate, back-dated |
| 6 |
# by two months (-v12 -w -1). |
| 7 |
# |
| 8 |
# old-ca+old-west: generate a CA that expired 1 month ago (-v 12 -w |
| 9 |
# -13). Use that to sign a certificate (for west) that is valid. |
| 10 |
# |
| 11 |
# hog-ca+hog=west: same; CA expired 1 month ago (-v 12 -w -13). Use |
| 12 |
# that to sign a certificate (for west) that is valid. |
| 13 |
|
| 14 |
ipsec certutil -m 1 -S -k rsa -x -w -2 -n new-ca -s "CN=new-ca" -v 12 -t "CT,C,C" -z ipsec.conf |
| 15 |
ipsec certutil -m 2 -S -k rsa -c new-ca -n new-west -s "CN=new-west" -v 12 -t "u,u,u" -z ipsec.conf |
| 16 |
|
| 17 |
ipsec certutil -m 1 -S -k rsa -x -w -13 -v 12 -n old-ca -s "CN=old-ca" -v 12 -t "CT,C,C" -z ipsec.conf |
| 18 |
ipsec certutil -m 2 -S -k rsa -c old-ca -w -11 -n old-west -s "CN=old-west" -v 12 -t "u,u,u" -z ipsec.conf |
| 19 |
|
| 20 |
ipsec certutil -m 1 -S -k rsa -x -w -13 -v 12 -n hog-ca -s "CN=hog-ca" -v 12 -t "CT,C,C" -z ipsec.conf |
| 21 |
ipsec certutil -m 2 -S -k rsa -c hog-ca -w -11 -n hog-west -s "CN=hog-west" -v 12 -t "u,u,u" -z ipsec.conf |
| 22 |
|
| 23 |
# Export the generated certificates and then delete them. This forces |
| 24 |
# west to send the cert as part of IKE_AUTH. |
| 25 |
|
| 26 |
ipsec pk12util -W secret -o OUTPUT/hog-west.p12 -n hog-west |
| 27 |
ipsec pk12util -W secret -o OUTPUT/new-west.p12 -n new-west |
| 28 |
ipsec pk12util -W secret -o OUTPUT/old-west.p12 -n old-west |
| 29 |
|
| 30 |
ipsec certutil -L -n hog-west -a > OUTPUT/hog-west.crt |
| 31 |
ipsec certutil -L -n new-west -a > OUTPUT/new-west.crt |
| 32 |
ipsec certutil -L -n old-west -a > OUTPUT/old-west.crt |
| 33 |
|
| 34 |
ipsec certutil -F -n hog-west |
| 35 |
ipsec certutil -F -n new-west |
| 36 |
ipsec certutil -F -n old-west |
| 37 |
|
| 38 |
# ipsec vfychain to confirm the above settings |
| 39 |
# |
| 40 |
# -p -p engages the new PKIX interface that pluto is using. |
| 41 |
# |
| 42 |
# -u 12 -> 1<<12 is #define certificateUsageIPsec (0x1000) |
| 43 |
# |
| 44 |
# -b YYMMDDHHMMZ (yea, CC is magic) |
| 45 |
|
| 46 |
NOW=$(date +%s) |
| 47 |
THEN=$((${NOW} - 45 * 24 * 60 * 60)) |
| 48 |
VFYDATE=$(date -d @${THEN} +%y%m%d000000Z) |
| 49 |
ipsec vfychain -v -u 12 -p -p -a OUTPUT/new-west.crt |
| 50 |
ipsec vfychain -v -u 12 -p -p -b ${VFYDATE} -a OUTPUT/new-west.crt |
| 51 |
! ipsec vfychain -v -u 12 -p -p -a OUTPUT/old-west.crt |
| 52 |
ipsec vfychain -v -u 12 -p -p -b ${VFYDATE} -a OUTPUT/old-west.crt |
| 53 |
! ipsec vfychain -v -u 12 -p -p -a OUTPUT/hog-west.crt |
| 54 |
ipsec vfychain -v -u 12 -p -p -b ${VFYDATE} -a OUTPUT/hog-west.crt |