| 1 |
/testing/guestbin/swan-prep --nokeys |
| 2 |
|
| 3 |
# Generate two CA and certificate pairs: |
| 4 |
# |
| 5 |
# new-ca+new-west: the CA is valid for twelve months back-dated by two |
| 6 |
# months (-w 2 -v 12); same for the certificate (i.e., valid now and |
| 7 |
# 45 days ago). |
| 8 |
# |
| 9 |
# old-ca+old-west: this time the CA expired a month ago (-w -13 -v 12) |
| 10 |
# and use this to sign a cert that is still valid (just) (-w -11 -v |
| 11 |
# 12) (i.e., both are valid 45 days ago, and cert can't be verified). |
| 12 |
|
| 13 |
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 |
| 14 |
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 |
| 15 |
|
| 16 |
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 |
| 17 |
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 |
| 18 |
|
| 19 |
# Export the certs old-west and new-west both as p12s and as .crts |
| 20 |
# (the latter is fed to verify) and then delete them so that the peer |
| 21 |
# has to include them in the IKE_AUTH request. |
| 22 |
|
| 23 |
ipsec pk12util -W secret -o OUTPUT/new-west.p12 -n new-west |
| 24 |
ipsec pk12util -W secret -o OUTPUT/old-west.p12 -n old-west |
| 25 |
|
| 26 |
ipsec certutil -L -n new-west -a > OUTPUT/new-west.crt |
| 27 |
ipsec certutil -L -n old-west -a > OUTPUT/old-west.crt |
| 28 |
|
| 29 |
ipsec certutil -F -n new-west |
| 30 |
ipsec certutil -F -n old-west |
| 31 |
|
| 32 |
# Use ipsec vfychain to confirm the above settings |
| 33 |
# |
| 34 |
# -p -p engages the new PKIX interface that pluto is using. |
| 35 |
# |
| 36 |
# -u 12 -> 1<<12 is #define certificateUsageIPsec (0x1000) |
| 37 |
# |
| 38 |
# -b YYMMDDHHMMZ (yea, CC is magic) |
| 39 |
# |
| 40 |
# THEN is 45 days ago which is when everything was valid (just before |
| 41 |
# old-ca expires). |
| 42 |
|
| 43 |
NOW=$(date +%s) |
| 44 |
THEN=$((${NOW} - 45 * 24 * 60 * 60)) |
| 45 |
VFYDATE=$(date -d @${THEN} +%y%m%d000000Z) |
| 46 |
|
| 47 |
ipsec vfychain -v -u 12 -p -p -a OUTPUT/new-west.crt |
| 48 |
! ipsec vfychain -v -u 12 -p -p -b ${VFYDATE} -a OUTPUT/new-west.crt |
| 49 |
! ipsec vfychain -v -u 12 -p -p -a OUTPUT/old-west.crt |
| 50 |
ipsec vfychain -v -u 12 -p -p -b ${VFYDATE} -a OUTPUT/old-west.crt |