build-certs-chroot 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913
  1. #!/bin/bash
  2. set -o errexit
  3. echo "Building certificates"
  4. # Disable leak detective when using pki as it produces warnings in tzset
  5. export LEAK_DETECTIVE_DISABLE=1
  6. # Determine testing directory
  7. DIR="$(dirname `readlink -f $0`)/.."
  8. # Define some global variables
  9. PROJECT="strongSwan Project"
  10. CA_DIR="${DIR}/hosts/winnetou/etc/ca"
  11. CA_KEY="${CA_DIR}/strongswanKey.pem"
  12. CA_CERT="${CA_DIR}/strongswanCert.pem"
  13. CA_CERT_DER="${CA_DIR}/strongswanCert.der"
  14. CA_CRL="${CA_DIR}/strongswan.crl"
  15. CA_LAST_CRL="${CA_DIR}/strongswan_last.crl"
  16. CA_CDP="http://crl.strongswan.org/strongswan.crl"
  17. CA_BASE_CDP="http://crl.strongswan.org/strongswan_base.crl"
  18. CA_OCSP="http://ocsp.strongswan.org:8880"
  19. #
  20. START=`date -d "-2 day" "+%d.%m.%y %T"`
  21. SH_END=`date -d "-1 day" "+%d.%m.%y %T"` # 1 day
  22. CA_END=`date -d "+3651 day" "+%d.%m.%y %T"` # 10 years
  23. IM_END=`date -d "+3286 day" "+%d.%m.%y %T"` # 9 years
  24. EE_END=`date -d "+2920 day" "+%d.%m.%y %T"` # 8 years
  25. SH_EXP=`date -d "-1 day" "+%y%m%d%H%M%SZ"` # 1 day
  26. IM_EXP=`date -d "+3286 day" "+%y%m%d%H%M%SZ"` # 9 years
  27. EE_EXP=`date -d "+2920 day" "+%y%m%d%H%M%SZ"` # 8 years
  28. NOW=`date "+%y%m%d%H%M%SZ"`
  29. #
  30. RESEARCH_DIR="${CA_DIR}/research"
  31. RESEARCH_KEY="${RESEARCH_DIR}/researchKey.pem"
  32. RESEARCH_CERT="${RESEARCH_DIR}/researchCert.pem"
  33. RESEARCH_CERT_DER="${RESEARCH_DIR}/researchCert.der"
  34. RESEARCH_CDP="http://crl.strongswan.org/research.crl"
  35. #
  36. SALES_DIR="${CA_DIR}/sales"
  37. SALES_KEY="${SALES_DIR}/salesKey.pem"
  38. SALES_CERT="${SALES_DIR}/salesCert.pem"
  39. SALES_CERT_DER="${SALES_DIR}/salesCert.der"
  40. SALES_CDP="http://crl.strongswan.org/sales.crl"
  41. #
  42. DUCK_DIR="${CA_DIR}/duck"
  43. DUCK_KEY="${DUCK_DIR}/duckKey.pem"
  44. DUCK_CERT="${DUCK_DIR}/duckCert.pem"
  45. #
  46. ECDSA_DIR="${CA_DIR}/ecdsa"
  47. ECDSA_KEY="${ECDSA_DIR}/strongswanKey.pem"
  48. ECDSA_CERT="${ECDSA_DIR}/strongswanCert.pem"
  49. ECDSA_CDP="http://crl.strongswan.org/strongswan_ecdsa.crl"
  50. #
  51. RFC3779_DIR="${CA_DIR}/rfc3779"
  52. RFC3779_KEY="${RFC3779_DIR}/strongswanKey.pem"
  53. RFC3779_CERT="${RFC3779_DIR}/strongswanCert.pem"
  54. RFC3779_CDP="http://crl.strongswan.org/strongswan_rfc3779.crl"
  55. #
  56. SHA3_RSA_DIR="${CA_DIR}/sha3-rsa"
  57. SHA3_RSA_KEY="${SHA3_RSA_DIR}/strongswanKey.pem"
  58. SHA3_RSA_CERT="${SHA3_RSA_DIR}/strongswanCert.pem"
  59. SHA3_RSA_CDP="http://crl.strongswan.org/strongswan_sha3_rsa.crl"
  60. #
  61. ED25519_DIR="${CA_DIR}/ed25519"
  62. ED25519_KEY="${ED25519_DIR}/strongswanKey.pem"
  63. ED25519_CERT="${ED25519_DIR}/strongswanCert.pem"
  64. ED25519_CDP="http://crl.strongswan.org/strongswan_ed25519.crl"
  65. #
  66. MONSTER_DIR="${CA_DIR}/monster"
  67. MONSTER_KEY="${MONSTER_DIR}/strongswanKey.pem"
  68. MONSTER_CERT="${MONSTER_DIR}/strongswanCert.pem"
  69. MONSTER_CDP="http://crl.strongswan.org/strongswan_monster.crl"
  70. MONSTER_CA_RSA_SIZE="8192"
  71. MONSTER_EE_RSA_SIZE="4096"
  72. #
  73. BLISS_DIR="${CA_DIR}/bliss"
  74. BLISS_KEY="${BLISS_DIR}/strongswan_blissKey.der"
  75. BLISS_CERT="${BLISS_DIR}/strongswan_blissCert.der"
  76. BLISS_CDP="http://crl.strongswan.org/strongswan_bliss.crl"
  77. #
  78. RSA_SIZE="3072"
  79. IPSEC_DIR="etc/ipsec.d"
  80. SWANCTL_DIR="etc/swanctl"
  81. TKM_DIR="etc/tkm"
  82. HOSTS="carol dave moon sun alice venus bob"
  83. TEST_DIR="${DIR}/tests"
  84. # Create directories
  85. mkdir -p ${CA_DIR}/certs
  86. mkdir -p ${CA_DIR}/keys
  87. mkdir -p ${RESEARCH_DIR}/certs
  88. mkdir -p ${RESEARCH_DIR}/keys
  89. mkdir -p ${SALES_DIR}/certs
  90. mkdir -p ${SALES_DIR}/keys
  91. mkdir -p ${DUCK_DIR}/certs
  92. mkdir -p ${ECDSA_DIR}/certs
  93. mkdir -p ${RFC3779_DIR}/certs
  94. mkdir -p ${SHA3_RSA_DIR}/certs
  95. mkdir -p ${ED25519_DIR}/certs
  96. mkdir -p ${MONSTER_DIR}/certs
  97. mkdir -p ${BLISS_DIR}/certs
  98. ################################################################################
  99. # strongSwan Root CA #
  100. ################################################################################
  101. # Generate strongSwan Root CA
  102. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${CA_KEY}
  103. pki --self --type rsa --in ${CA_KEY} --not-before "${START}" --not-after "${CA_END}" \
  104. --ca --pathlen 1 --dn "C=CH, O=${PROJECT}, CN=strongSwan Root CA" \
  105. --outform pem > ${CA_CERT}
  106. # Distribute strongSwan Root CA certificate
  107. for h in ${HOSTS}
  108. do
  109. HOST_DIR="${DIR}/hosts/${h}"
  110. mkdir -p ${HOST_DIR}/${IPSEC_DIR}/cacerts
  111. mkdir -p ${HOST_DIR}/${SWANCTL_DIR}/x509ca
  112. cp ${CA_CERT} ${HOST_DIR}/${IPSEC_DIR}/cacerts
  113. cp ${CA_CERT} ${HOST_DIR}/${SWANCTL_DIR}/x509ca
  114. done
  115. # Put a copy onto the alice FreeRADIUS server
  116. mkdir -p ${DIR}/hosts/alice/etc/raddb/certs
  117. cp ${CA_CERT} ${DIR}/hosts/alice/etc/raddb/certs
  118. # Convert strongSwan Root CA certificate into DER format
  119. openssl x509 -in ${CA_CERT} -outform der -out ${CA_CERT_DER}
  120. # Generate a stale CRL
  121. pki --signcrl --cakey ${CA_KEY} --cacert ${CA_CERT} \
  122. --this-update "${START}" --lifetime 1 > ${CA_LAST_CRL}
  123. # Put a CRL copy into the ikev2/crl-ldap scenario to be used as a stale crl
  124. TEST="${TEST_DIR}/ikev2/crl-ldap"
  125. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/crls
  126. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/crls
  127. cp ${CA_LAST_CRL} ${TEST}/hosts/carol/${IPSEC_DIR}/crls/stale.crl
  128. cp ${CA_LAST_CRL} ${TEST}/hosts/moon/${IPSEC_DIR}/crls/stale.crl
  129. # Generate host keys
  130. for h in ${HOSTS}
  131. do
  132. HOST_DIR="${DIR}/hosts/${h}"
  133. HOST_KEY="${HOST_DIR}/${IPSEC_DIR}/private/${h}Key.pem"
  134. mkdir -p ${HOST_DIR}/${IPSEC_DIR}/private
  135. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${HOST_KEY}
  136. # Put a copy into swanctl directory tree
  137. mkdir -p ${HOST_DIR}/${SWANCTL_DIR}/rsa
  138. cp ${HOST_KEY} ${HOST_DIR}/${SWANCTL_DIR}/rsa
  139. # Convert host key into DER format
  140. openssl rsa -in ${HOST_KEY} -outform der -out ${CA_DIR}/keys/${h}Key.der \
  141. 2> /dev/null
  142. done
  143. # Put DER-encoded moon private key and Root CA certificate into tkm scenarios
  144. for t in host2host-initiator host2host-responder host2host-xfrmproxy \
  145. net2net-initiator net2net-xfrmproxy xfrmproxy-expire xfrmproxy-rekey
  146. do
  147. TEST="${TEST_DIR}/tkm/${t}"
  148. mkdir -p ${TEST}/hosts/moon/${TKM_DIR}
  149. cp ${CA_DIR}/keys/moonKey.der ${CA_CERT_DER} ${TEST}/hosts/moon/${TKM_DIR}
  150. done
  151. # Put DER_encoded sun private key and Root CA certificate into tkm scenarios
  152. TEST="${TEST_DIR}/tkm/multiple-clients"
  153. mkdir -p ${TEST}/hosts/sun/${TKM_DIR}
  154. cp ${CA_DIR}/keys/sunKey.der ${CA_CERT_DER} ${TEST}/hosts/sun/${TKM_DIR}
  155. # Convert moon private key into unencrypted PKCS#8 format
  156. TEST="${TEST_DIR}/ikev2/rw-pkcs8"
  157. HOST_KEY="${DIR}/hosts/moon/${SWANCTL_DIR}/rsa/moonKey.pem"
  158. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/moonKey.pem"
  159. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  160. openssl pkcs8 -in ${HOST_KEY} -nocrypt -topk8 -out ${TEST_KEY}
  161. # Convert carol private key into v1.5 DES encrypted PKCS#8 format
  162. HOST_KEY="${DIR}/hosts/carol/${SWANCTL_DIR}/rsa/carolKey.pem"
  163. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey.pem"
  164. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  165. openssl pkcs8 -in ${HOST_KEY} -nocrypt -topk8 -v1 PBE-MD5-DES \
  166. -passout "pass:nH5ZQEWtku0RJEZ6" -out ${TEST_KEY}
  167. # Convert dave private key into v2.0 AES-128 encrypted PKCS#8 format
  168. HOST_KEY="${DIR}/hosts/dave/${SWANCTL_DIR}/rsa/daveKey.pem"
  169. TEST_KEY="${TEST}/hosts/dave/${IPSEC_DIR}/private/daveKey.pem"
  170. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  171. openssl pkcs8 -in ${HOST_KEY} -nocrypt -topk8 -v2 aes128 \
  172. -passout "pass:OJlNZBx+80dLh4wC6fw5LmBd" -out ${TEST_KEY}
  173. ################################################################################
  174. # Public Key Extraction #
  175. ################################################################################
  176. # Extract the raw moon public key for the swanctl/net2net-pubkey scenario
  177. TEST="${TEST_DIR}/swanctl/net2net-pubkey"
  178. TEST_PUB="${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey/moonPub.pem"
  179. HOST_KEY="${DIR}/hosts/moon/${SWANCTL_DIR}/rsa/moonKey.pem"
  180. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  181. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/pubkey
  182. pki --pub --type rsa --in ${HOST_KEY} --outform pem > ${TEST_PUB}
  183. cp ${TEST_PUB} ${TEST}/hosts/sun/${SWANCTL_DIR}/pubkey
  184. # Put a copy into the following ikev2 scenarios
  185. for t in net2net-dnssec net2net-pubkey rw-dnssec
  186. do
  187. TEST="${TEST_DIR}/ikev2/${t}"
  188. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  189. cp ${TEST_PUB} ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  190. done
  191. # Put a copy into the ikev2/net2net-pubkey scenario
  192. TEST="${TEST_DIR}/ikev2/net2net-pubkey"
  193. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/certs
  194. cp ${TEST_PUB} ${TEST}/hosts/sun/${IPSEC_DIR}/certs
  195. # Put a copy into the swanctl/rw-dnssec scenario
  196. TEST="${TEST_DIR}/swanctl/rw-dnssec"
  197. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  198. cp ${TEST_PUB} ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  199. # Put a copy into the following swanctl scenarios
  200. for t in rw-pubkey-anon rw-pubkey-keyid
  201. do
  202. TEST="${TEST_DIR}/swanctl/${t}"
  203. for h in moon carol dave
  204. do
  205. mkdir -p ${TEST}/hosts/${h}/${SWANCTL_DIR}/pubkey
  206. cp ${TEST_PUB} ${TEST}/hosts/${h}/${SWANCTL_DIR}/pubkey
  207. done
  208. done
  209. # Extract the raw sun public key for the swanctl/net2net-pubkey scenario
  210. TEST="${TEST_DIR}/swanctl/net2net-pubkey"
  211. TEST_PUB="${TEST}/hosts/sun/${SWANCTL_DIR}/pubkey/sunPub.pem"
  212. HOST_KEY="${DIR}/hosts/sun/${SWANCTL_DIR}/rsa/sunKey.pem"
  213. pki --pub --type rsa --in ${HOST_KEY} --outform pem > ${TEST_PUB}
  214. cp ${TEST_PUB} ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  215. # Put a copy into the ikev2/net2net-dnssec scenario
  216. TEST="${TEST_DIR}/ikev2/net2net-dnssec"
  217. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/certs
  218. cp ${TEST_PUB} ${TEST}/hosts/sun/${IPSEC_DIR}/certs
  219. # Put a copy into the ikev2/net2net-pubkey scenario
  220. TEST="${TEST_DIR}/ikev2/net2net-pubkey"
  221. cp ${TEST_PUB} ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  222. cp ${TEST_PUB} ${TEST}/hosts/sun/${IPSEC_DIR}/certs
  223. # Put a copy into the swanctl/rw-pubkey-anon scenario
  224. TEST="${TEST_DIR}/swanctl/rw-pubkey-anon"
  225. cp ${TEST_PUB} ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  226. # Extract the raw carol public key for the swanctl/rw-dnssec scenario
  227. TEST="${TEST_DIR}/swanctl/rw-dnssec"
  228. TEST_PUB="${TEST}/hosts/carol/${SWANCTL_DIR}/pubkey/carolPub.pem"
  229. HOST_KEY="${DIR}/hosts/carol/${SWANCTL_DIR}/rsa/carolKey.pem"
  230. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/pubkey
  231. pki --pub --type rsa --in ${HOST_KEY} --outform pem > ${TEST_PUB}
  232. # Put a copy into the swanctl/rw-pubkey-anon scenario
  233. TEST="${TEST_DIR}/swanctl/rw-pubkey-anon"
  234. cp ${TEST_PUB} ${TEST}/hosts/carol/${SWANCTL_DIR}/pubkey
  235. cp ${TEST_PUB} ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  236. # Put a copy into the swanctl/rw-pubkey-keyid scenario
  237. TEST="${TEST_DIR}/swanctl/rw-pubkey-keyid"
  238. cp ${TEST_PUB} ${TEST}/hosts/carol/${SWANCTL_DIR}/pubkey
  239. cp ${TEST_PUB} ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  240. # Extract the raw dave public key for the swanctl/rw-dnssec scenario
  241. TEST="${TEST_DIR}/swanctl/rw-dnssec"
  242. TEST_PUB="${TEST}/hosts/dave/${SWANCTL_DIR}/pubkey/davePub.pem"
  243. HOST_KEY="${DIR}/hosts/dave/${SWANCTL_DIR}/rsa/daveKey.pem"
  244. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/pubkey
  245. pki --pub --type rsa --in ${HOST_KEY} --outform pem > ${TEST_PUB}
  246. # Put a copy into the swanctl/rw-pubkey-anon scenario
  247. TEST="${TEST_DIR}/swanctl/rw-pubkey-anon"
  248. cp ${TEST_PUB} ${TEST}/hosts/dave/${SWANCTL_DIR}/pubkey
  249. cp ${TEST_PUB} ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  250. # Put a copy into the swanctl/rw-pubkey-keyid scenario
  251. TEST="${TEST_DIR}/swanctl/rw-pubkey-keyid"
  252. cp ${TEST_PUB} ${TEST}/hosts/dave/${SWANCTL_DIR}/pubkey
  253. cp ${TEST_PUB} ${TEST}/hosts/moon/${SWANCTL_DIR}/pubkey
  254. ################################################################################
  255. # Host Certificate Generation #
  256. ################################################################################
  257. # function issue_cert: serial host cn [ou]
  258. issue_cert()
  259. {
  260. # does optional OU argument exist?
  261. if [ -z "${4}" ]
  262. then
  263. OU=""
  264. else
  265. OU=" OU=${4},"
  266. fi
  267. HOST_DIR="${DIR}/hosts/${2}"
  268. HOST_KEY="${HOST_DIR}/${IPSEC_DIR}/private/${2}Key.pem"
  269. HOST_CERT="${HOST_DIR}/${IPSEC_DIR}/certs/${2}Cert.pem"
  270. mkdir -p ${HOST_DIR}/${IPSEC_DIR}/certs
  271. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  272. --in ${HOST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${3} \
  273. --serial ${1} --dn "C=CH, O=${PROJECT},${OU} CN=${3}" \
  274. --outform pem > ${HOST_CERT}
  275. cp ${HOST_CERT} ${CA_DIR}/certs/${1}.pem
  276. # Put a certificate copy into swanctl directory tree
  277. mkdir -p ${HOST_DIR}/${SWANCTL_DIR}/x509
  278. cp ${HOST_CERT} ${HOST_DIR}/${SWANCTL_DIR}/x509
  279. }
  280. # Generate host certificates
  281. issue_cert 01 carol carol@strongswan.org Research
  282. issue_cert 02 dave dave@strongswan.org Accounting
  283. issue_cert 03 moon moon.strongswan.org
  284. issue_cert 04 sun sun.strongswan.org
  285. issue_cert 05 alice alice@strongswan.org Sales
  286. issue_cert 06 venus venus.strongswan.org
  287. issue_cert 07 bob bob@strongswan.org Research
  288. # Create PKCS#12 file for moon
  289. TEST="${TEST_DIR}/ikev2/net2net-pkcs12"
  290. HOST_KEY="${DIR}/hosts/moon/${SWANCTL_DIR}/rsa/moonKey.pem"
  291. HOST_CERT="${DIR}/hosts/moon/${SWANCTL_DIR}/x509/moonCert.pem"
  292. MOON_PKCS12="${TEST}/hosts/moon/${IPSEC_DIR}/private/moonCert.p12"
  293. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  294. openssl pkcs12 -export -inkey ${HOST_KEY} -in ${HOST_CERT} -name "moon" \
  295. -certfile ${CA_CERT} -caname "strongSwan Root CA" \
  296. -aes128 -passout "pass:kUqd8O7mzbjXNJKQ" > ${MOON_PKCS12} 2> /dev/null
  297. # Create PKCS#12 file for sun
  298. HOST_KEY="${DIR}/hosts/sun/${SWANCTL_DIR}/rsa/sunKey.pem"
  299. HOST_CERT="${DIR}/hosts/sun/${SWANCTL_DIR}/x509/sunCert.pem"
  300. SUN_PKCS12="${TEST}/hosts/sun/${IPSEC_DIR}/private/sunCert.p12"
  301. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/private
  302. openssl pkcs12 -export -inkey ${HOST_KEY} -in ${HOST_CERT} -name "sun" \
  303. -certfile ${CA_CERT} -caname "strongSwan Root CA" \
  304. -aes128 -passout "pass:IxjQVCF3JGI+MoPi" > ${SUN_PKCS12} 2> /dev/null
  305. # Put a PKCS#12 copy into the botan/net2net-pkcs12 scenario
  306. for t in botan/net2net-pkcs12 openssl-ikev2/net2net-pkcs12
  307. do
  308. TEST="${TEST_DIR}/${t}"
  309. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs12
  310. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/pkcs12
  311. cp ${MOON_PKCS12} ${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs12
  312. cp ${SUN_PKCS12} ${TEST}/hosts/sun/${SWANCTL_DIR}/pkcs12
  313. done
  314. ################################################################################
  315. # DNSSEC Zone Files #
  316. ################################################################################
  317. # Store moon and sun certificates in strongswan.org zone
  318. ZONE_FILE="${CA_DIR}/db.strongswan.org.certs-and-keys"
  319. echo "; Automatically generated for inclusion in zone file" > ${ZONE_FILE}
  320. for h in moon sun
  321. do
  322. HOST_CERT=${DIR}/hosts/${h}/${SWANCTL_DIR}/x509/${h}Cert.pem
  323. cert=$(grep --invert-match ^----- ${HOST_CERT}| sed -e 's/^/\t\t\t\t/')
  324. echo -e "${h}\tIN\tCERT\t( 1 0 0\n${cert}\n\t\t\t\t)" >> ${ZONE_FILE}
  325. done
  326. # Store public keys in strongswan.org zone
  327. echo ";" >> ${ZONE_FILE}
  328. for h in moon sun carol dave
  329. do
  330. HOST_CERT=${DIR}/hosts/${h}/${SWANCTL_DIR}/x509/${h}Cert.pem
  331. pubkey=$(pki --pub --type x509 --in ${HOST_CERT} --outform dnskey | sed 's/\(.\{0,64\}\)/\t\t\t\t\1\n/g')
  332. echo -e "${h}\tIN\tIPSECKEY\t( 10 3 2 ${h}.strongswan.org.\n${pubkey}\n\t\t\t\t)" >> ${ZONE_FILE}
  333. done
  334. # Generate a carol certificate for the swanctl/crl-to-cache scenario with base CDP
  335. TEST="${TEST_DIR}/swanctl/crl-to-cache"
  336. TEST_CERT="${TEST}/hosts/carol/${SWANCTL_DIR}/x509/carolCert.pem"
  337. HOST_KEY="${DIR}/hosts/carol/${SWANCTL_DIR}/rsa/carolKey.pem"
  338. CN="carol@strongswan.org"
  339. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  340. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_BASE_CDP} --type rsa \
  341. --in ${HOST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  342. --serial 01 --dn "C=CH, O=${PROJECT}, OU=Research, CN=${CN}" \
  343. --outform pem > ${TEST_CERT}
  344. # Generate a moon certificate for the swanctl/crl-to-cache scenario with base CDP
  345. TEST_CERT="${TEST}/hosts/moon/${SWANCTL_DIR}/x509/moonCert.pem"
  346. HOST_KEY="${DIR}/hosts/moon/${SWANCTL_DIR}/rsa/moonKey.pem"
  347. CN="moon.strongswan.org"
  348. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  349. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_BASE_CDP} --type rsa \
  350. --in ${HOST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  351. --serial 03 --dn "C=CH, O=${PROJECT}, CN=${CN}" \
  352. --outform pem > ${TEST_CERT}
  353. # Encrypt carolKey.pem
  354. HOST_KEY="${DIR}/hosts/carol/${IPSEC_DIR}/private/carolKey.pem"
  355. KEY_PWD="nH5ZQEWtku0RJEZ6"
  356. openssl rsa -in ${HOST_KEY} -aes128 --passout pass:${KEY_PWD} -out ${HOST_KEY} \
  357. 2> /dev/null
  358. # Put a copy into the ikev2/dynamic-initiator scenario
  359. for t in ikev2/dynamic-initiator ikev1/dynamic-initiator ikev1/dynamic-responder
  360. do
  361. TEST="${TEST_DIR}/${t}"
  362. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  363. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  364. cp ${HOST_KEY} ${TEST}/hosts/dave/${IPSEC_DIR}/private
  365. cp ${CA_DIR}/certs/01.pem ${TEST}/hosts/dave/${IPSEC_DIR}/certs/carolCert.pem
  366. done
  367. # Put a copy into the swanctl/rw-cert scenario
  368. TEST="${TEST_DIR}/swanctl/rw-cert"
  369. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/rsa
  370. cp ${HOST_KEY} ${TEST}/hosts/carol/${SWANCTL_DIR}/rsa
  371. # Generate another carol certificate and revoke it
  372. TEST="${TEST_DIR}/ikev2/crl-revoked"
  373. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey.pem"
  374. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert.pem"
  375. CN="carol@strongswan.org"
  376. SERIAL="08"
  377. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  378. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  379. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  380. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  381. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  382. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=${CN}" \
  383. --outform pem > ${TEST_CERT}
  384. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  385. pki --signcrl --cakey ${CA_KEY} --cacert ${CA_CERT} --reason "key-compromise" \
  386. --serial ${SERIAL} > ${CA_CRL}
  387. cp ${CA_CRL} ${CA_LAST_CRL}
  388. # Put a copy into the ikev2/ocsp-revoked scenario
  389. TEST="${TEST_DIR}/ikev2/ocsp-revoked"
  390. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  391. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  392. cp ${TEST_KEY} ${TEST}/hosts/carol/${IPSEC_DIR}/private
  393. cp ${TEST_CERT} ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  394. # Generate another carol certificate with SN=002
  395. TEST="${TEST_DIR}/ikev2/two-certs"
  396. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey-002.pem"
  397. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert-002.pem"
  398. SERIAL="09"
  399. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  400. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  401. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  402. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  403. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  404. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, SN=002, CN=${CN}" \
  405. --outform pem > ${TEST_CERT}
  406. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  407. ################################################################################
  408. # Research CA Certificate Generation #
  409. ################################################################################
  410. # Generate a Research CA certificate signed by the Root CA and revoke it
  411. TEST="${TEST_DIR}/ikev2/multi-level-ca-revoked"
  412. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/cacerts/researchCert.pem"
  413. SERIAL="0A"
  414. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts/
  415. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${RESEARCH_KEY}
  416. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  417. --in ${RESEARCH_KEY} --not-before "${START}" --not-after "${IM_END}" --ca \
  418. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=Research CA" \
  419. --outform pem > ${TEST_CERT}
  420. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  421. pki --signcrl --cakey ${CA_KEY} --cacert ${CA_CERT} --reason "ca-compromise" \
  422. --serial ${SERIAL} --lastcrl ${CA_LAST_CRL} > ${CA_CRL}
  423. rm ${CA_LAST_CRL}
  424. # Generate Research CA with the same private key as above signed by Root CA
  425. SERIAL="0B"
  426. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  427. --in ${RESEARCH_KEY} --not-before "${START}" --not-after "${IM_END}" --ca \
  428. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=Research CA" \
  429. --outform pem > ${RESEARCH_CERT}
  430. cp ${RESEARCH_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  431. # Put a certificate copy into the following scenarios
  432. for t in ikev1/multi-level-ca ikev2/multi-level-ca ikev2/multi-level-ca-ldap \
  433. ikev2/multi-level-ca-pathlen ikev2/multi-level-ca-strict \
  434. ikev2/ocsp-multi-level ikev2/ocsp-strict-ifuri
  435. do
  436. TEST="${TEST_DIR}/${t}"
  437. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  438. cp ${RESEARCH_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  439. done
  440. for t in ikev1/multi-level-ca-cr-init ikev1/multi-level-ca-cr-resp \
  441. ikev2/multi-level-ca-cr-init ikev2/multi-level-ca-cr-resp
  442. do
  443. TEST="${TEST_DIR}/${t}"
  444. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/cacerts
  445. cp ${RESEARCH_CERT} ${TEST}/hosts/carol/${IPSEC_DIR}/cacerts
  446. done
  447. for t in multi-level-ca ocsp-multi-level
  448. do
  449. TEST="${TEST_DIR}/swanctl/${t}"
  450. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509ca
  451. cp ${RESEARCH_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509ca
  452. done
  453. # Convert Research CA certificate into DER format
  454. openssl x509 -in ${RESEARCH_CERT} -outform der -out ${RESEARCH_CERT_DER}
  455. # Generate Research CA with the same private key as above but invalid CDP
  456. TEST="${TEST_DIR}/ikev2/multi-level-ca-skipped"
  457. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/cacerts/researchCert.pem"
  458. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  459. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --type rsa \
  460. --crl "http://crl.strongswan.org/not-available.crl" \
  461. --in ${RESEARCH_KEY} --not-before "${START}" --not-after "${IM_END}" --ca \
  462. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=Research CA" \
  463. --outform pem > ${TEST_CERT}
  464. ################################################################################
  465. # Sales CA Certificate Generation #
  466. ################################################################################
  467. # Generate Sales CA signed by Root CA
  468. SERIAL="0C"
  469. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${SALES_KEY}
  470. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  471. --in ${SALES_KEY} --not-before "${START}" --not-after "${IM_END}" --ca \
  472. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Sales, CN=Sales CA" \
  473. --outform pem > ${SALES_CERT}
  474. cp ${SALES_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  475. # Put a certificate copy into the following scenarios
  476. for t in ikev1/multi-level-ca ikev2/multi-level-ca ikev2/multi-level-ca-ldap \
  477. ikev2/multi-level-ca-strict ikev2/ocsp-multi-level \
  478. ikev2/ocsp-multi-level ikev2/ocsp-strict-ifuri
  479. do
  480. TEST="${TEST_DIR}/${t}"
  481. cp ${SALES_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  482. done
  483. for t in ikev1/multi-level-ca-cr-init ikev1/multi-level-ca-cr-resp \
  484. ikev2/multi-level-ca-cr-init ikev2/multi-level-ca-cr-resp
  485. do
  486. TEST="${TEST_DIR}/${t}"
  487. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/cacerts
  488. cp ${SALES_CERT} ${TEST}/hosts/dave/${IPSEC_DIR}/cacerts
  489. done
  490. for t in multi-level-ca ocsp-multi-level
  491. do
  492. TEST="${TEST_DIR}/swanctl/${t}"
  493. cp ${SALES_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509ca
  494. done
  495. # Convert Sales CA certificate into DER format
  496. openssl x509 -in ${SALES_CERT} -outform der -out ${SALES_CERT_DER}
  497. # Generate an AES-128 encrypted moon key and a SHA-224 hashed certificate
  498. TEST="${TEST_DIR}/ikev2/strong-keys-certs"
  499. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/moonKey-aes128.pem"
  500. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/certs/moonCert-sha224.pem"
  501. KEY_PWD="gOQHdrSWeFuiZtYPetWuyzHW"
  502. CN="moon.strongswan.org"
  503. SERIAL="0D"
  504. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  505. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  506. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  507. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  508. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  509. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=SHA-224, CN=${CN}" \
  510. --digest sha224 --outform pem > ${TEST_CERT}
  511. openssl rsa -in ${TEST_KEY} -aes128 --passout pass:${KEY_PWD} -out ${TEST_KEY} \
  512. 2> /dev/null
  513. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  514. # Generate an AES-192 encrypted carol key and a SHA-384 hashed certificate
  515. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey-aes192.pem"
  516. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert-sha384.pem"
  517. KEY_PWD="ITP/H4lSHqGpUGmCpgNDklbzTNV+swjA"
  518. CN="carol@strongswan.org"
  519. SERIAL="0E"
  520. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  521. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  522. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  523. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  524. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  525. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=SHA-384, CN=${CN}" \
  526. --digest sha384 --outform pem > ${TEST_CERT}
  527. openssl rsa -in ${TEST_KEY} -aes192 --passout pass:${KEY_PWD} -out ${TEST_KEY} \
  528. 2> /dev/null
  529. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  530. # Generate an AES-256 encrypted dave key and a SHA-512 hashed certificate
  531. TEST_KEY="${TEST}/hosts/dave/${IPSEC_DIR}/private/daveKey-aes256.pem"
  532. TEST_CERT="${TEST}/hosts/dave/${IPSEC_DIR}/certs/daveCert-sha512.pem"
  533. KEY_PWD="MeFnDN7VUbj+qU/bkgRIFvbCketIk2wrrs5Ii8297N2v"
  534. CN="dave@strongswan.org"
  535. SERIAL="0F"
  536. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  537. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  538. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  539. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  540. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  541. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=SHA-512, CN=${CN}" \
  542. --digest sha512 --outform pem > ${TEST_CERT}
  543. openssl rsa -in ${TEST_KEY} -aes256 --passout pass:${KEY_PWD} -out ${TEST_KEY} \
  544. 2> /dev/null
  545. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  546. # Generate another carol certificate with an OCSP URI
  547. TEST="${TEST_DIR}/ikev2/ocsp-signer-cert"
  548. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey.pem"
  549. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert.pem"
  550. CN="carol@strongswan.org"
  551. SERIAL="10"
  552. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  553. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  554. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  555. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  556. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  557. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=OCSP, CN=${CN}" \
  558. --ocsp ${CA_OCSP} --outform pem > ${TEST_CERT}
  559. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  560. # Put a copy into the ikev2/ocsp-timeouts-good scenario
  561. TEST="${TEST_DIR}/ikev2/ocsp-timeouts-good"
  562. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  563. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  564. cp ${TEST_KEY} ${TEST}/hosts/carol/${IPSEC_DIR}/private
  565. cp ${TEST_CERT} ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  566. # Put a copy into the swanctl/ocsp-signer-cert scenario
  567. for t in ocsp-signer-cert ocsp-disabled
  568. do
  569. cd "${TEST_DIR}/swanctl/${t}/hosts/carol/${SWANCTL_DIR}"
  570. mkdir -p rsa x509
  571. cp ${TEST_KEY} rsa
  572. cp ${TEST_CERT} x509
  573. done
  574. # Generate an OCSP Signing certificate for the strongSwan Root CA
  575. TEST_KEY="${CA_DIR}/ocspKey.pem"
  576. TEST_CERT="${CA_DIR}/ocspCert.pem"
  577. CN="ocsp.strongswan.org"
  578. OU="OCSP Signing Authority"
  579. SERIAL="11"
  580. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  581. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  582. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  583. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=${OU}, CN=${CN}" \
  584. --flag ocspSigning --outform pem > ${TEST_CERT}
  585. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  586. # Generate a self-signed OCSP Signing certificate
  587. TEST_KEY="${CA_DIR}/ocspKey-self.pem"
  588. TEST_CERT="${CA_DIR}/ocspCert-self.pem"
  589. OU="OCSP Self-Signed Authority"
  590. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  591. pki --self --type rsa --in ${TEST_KEY} --flag ocspSigning \
  592. --not-before "${START}" --not-after "${CA_END}" --san ${CN} \
  593. --dn "C=CH, O=${PROJECT}, OU=${OU}, CN=${CN}" \
  594. --outform pem > ${TEST_CERT}
  595. # Copy self-signed OCSP Signing certificate to ikev2/ocsp-local-cert scenario
  596. TEST="${TEST_DIR}/ikev2/ocsp-local-cert"
  597. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/ocspcerts
  598. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/ocspcerts
  599. cp ${TEST_CERT} ${TEST}/hosts/carol/${IPSEC_DIR}/ocspcerts
  600. cp ${TEST_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/ocspcerts
  601. # Generate mars virtual server certificate
  602. TEST="${TEST_DIR}/ha/both-active"
  603. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/marsKey.pem"
  604. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/certs/marsCert.pem"
  605. CN="mars.strongswan.org"
  606. OU="Virtual VPN Gateway"
  607. SERIAL="12"
  608. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  609. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  610. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  611. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  612. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  613. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=${OU}, CN=${CN}" \
  614. --flag serverAuth --outform pem > ${TEST_CERT}
  615. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  616. # Put a copy into the mirrored gateway
  617. mkdir -p ${TEST}/hosts/alice/${IPSEC_DIR}/private
  618. mkdir -p ${TEST}/hosts/alice/${IPSEC_DIR}/certs
  619. cp ${TEST_KEY} ${TEST}/hosts/alice/${IPSEC_DIR}/private
  620. cp ${TEST_CERT} ${TEST}/hosts/alice/${IPSEC_DIR}/certs
  621. # Put a copy into the ha/active-passive and ikev2-redirect-active scenarios
  622. for t in "ha/active-passive" "ikev2/redirect-active"
  623. do
  624. TEST="${TEST_DIR}/${t}"
  625. for h in alice moon
  626. do
  627. mkdir -p ${TEST}/hosts/${h}/${IPSEC_DIR}/private
  628. mkdir -p ${TEST}/hosts/${h}/${IPSEC_DIR}/certs
  629. cp ${TEST_KEY} ${TEST}/hosts/${h}/${IPSEC_DIR}/private
  630. cp ${TEST_CERT} ${TEST}/hosts/${h}/${IPSEC_DIR}/certs
  631. done
  632. done
  633. # Generate moon certificate with an unsupported critical X.509 extension
  634. TEST="${TEST_DIR}/ikev2/critical-extension"
  635. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/moonKey.pem"
  636. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/certs/moonCert.pem"
  637. CN="moon.strongswan.org"
  638. SERIAL="13"
  639. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  640. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  641. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  642. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  643. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  644. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Critical Extension, CN=${CN}" \
  645. --critical 1.3.6.1.4.1.36906.1 --flag serverAuth \
  646. --outform pem > ${TEST_CERT}
  647. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  648. # Put a copy in the openssl-ikev2/critical extension scenario
  649. TEST="${TEST_DIR}/openssl-ikev2/critical-extension"
  650. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/rsa
  651. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  652. cp ${TEST_KEY} ${TEST}/hosts/moon/${SWANCTL_DIR}/rsa
  653. cp ${TEST_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  654. # Generate sun certificate with an unsupported critical X.509 extension
  655. TEST="${TEST_DIR}/ikev2/critical-extension"
  656. TEST_KEY="${TEST}/hosts/sun/${IPSEC_DIR}/private/sunKey.pem"
  657. TEST_CERT="${TEST}/hosts/sun/${IPSEC_DIR}/certs/sunCert.pem"
  658. CN="sun.strongswan.org"
  659. SERIAL="14"
  660. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/private
  661. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/certs
  662. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  663. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  664. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  665. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Critical Extension, CN=${CN}" \
  666. --critical 1.3.6.1.4.1.36906.1 --flag serverAuth \
  667. --outform pem > ${TEST_CERT}
  668. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  669. # Put a copy in the openssl-ikev2/critical extension scenario
  670. TEST="${TEST_DIR}/openssl-ikev2/critical-extension"
  671. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/rsa
  672. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/x509
  673. cp ${TEST_KEY} ${TEST}/hosts/sun/${SWANCTL_DIR}/rsa
  674. cp ${TEST_CERT} ${TEST}/hosts/sun/${SWANCTL_DIR}/x509
  675. # Generate winnetou server certificate
  676. HOST_KEY="${CA_DIR}/winnetouKey.pem"
  677. HOST_CERT="${CA_DIR}/winnetouCert.pem"
  678. CN="winnetou.strongswan.org"
  679. SERIAL="15"
  680. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${HOST_KEY}
  681. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  682. --in ${HOST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  683. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, CN=${CN}" \
  684. --flag serverAuth --outform pem > ${HOST_CERT}
  685. cp ${HOST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  686. # Generate AAA server certificate
  687. TEST="${TEST_DIR}/tnc/tnccs-20-pdp-eap"
  688. TEST_KEY="${TEST}/hosts/alice/${SWANCTL_DIR}/rsa/aaaKey.pem"
  689. TEST_CERT="${TEST}/hosts/alice/${SWANCTL_DIR}/x509/aaaCert.pem"
  690. CN="aaa.strongswan.org"
  691. SERIAL="16"
  692. cd "${TEST}/hosts/alice/${SWANCTL_DIR}"
  693. mkdir -p rsa x509
  694. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  695. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  696. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  697. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, CN=${CN}" \
  698. --flag serverAuth --outform pem > ${TEST_CERT}
  699. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  700. # Put a copy into various tnc scenarios
  701. for t in tnccs-20-pdp-pt-tls tnccs-20-ev-pt-tls tnccs-20-hcd-eap
  702. do
  703. cd "${TEST_DIR}/tnc/${t}/hosts/alice/${SWANCTL_DIR}"
  704. mkdir -p rsa x509
  705. cp ${TEST_KEY} rsa
  706. cp ${TEST_CERT} x509
  707. done
  708. # Put a copy into the alice FreeRADIUS server
  709. cp ${TEST_KEY} ${TEST_CERT} ${DIR}/hosts/alice/etc/raddb/certs
  710. ################################################################################
  711. # strongSwan Attribute Authority #
  712. ################################################################################
  713. # Generate Attritbute Authority certificate
  714. TEST="${TEST_DIR}/ikev2/acert-cached"
  715. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/aaKey.pem"
  716. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/aacerts/aaCert.pem"
  717. CN="strongSwan Attribute Authority"
  718. SERIAL="17"
  719. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  720. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/aacerts
  721. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/acerts
  722. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  723. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  724. --in ${TEST_KEY} --not-before "${START}" --not-after "${IM_END}" \
  725. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, CN=${CN}" \
  726. --outform pem > ${TEST_CERT}
  727. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  728. # Generate carol's attribute certificate for sales and finance
  729. ACERT="${TEST}/hosts/moon/${IPSEC_DIR}/acerts/carol-sales-finance.pem"
  730. pki --acert --issuerkey ${TEST_KEY} --issuercert ${TEST_CERT} \
  731. --in ${CA_DIR}/certs/01.pem --group sales --group finance \
  732. --not-before "${START}" --not-after "${EE_END}" --outform pem > ${ACERT}
  733. # Generate dave's expired attribute certificate for sales
  734. ACERT="${TEST}/hosts/moon/${IPSEC_DIR}/acerts/dave-sales-expired.pem"
  735. pki --acert --issuerkey ${TEST_KEY} --issuercert ${TEST_CERT} \
  736. --in ${CA_DIR}/certs/02.pem --group sales \
  737. --not-before "${START}" --not-after "${SH_END}" --outform pem > ${ACERT}
  738. # Generate dave's attribute certificate for marketing
  739. ACERT_DM="${TEST}/hosts/moon/${IPSEC_DIR}/acerts/dave-marketing.pem"
  740. pki --acert --issuerkey ${TEST_KEY} --issuercert ${TEST_CERT} \
  741. --in ${CA_DIR}/certs/02.pem --group marketing \
  742. --not-before "${SH_END}" --not-after "${EE_END}" --outform pem > ${ACERT_DM}
  743. # Put a copy into the ikev2/acert-fallback scenario
  744. TEST="${TEST_DIR}/ikev2/acert-fallback"
  745. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  746. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/aacerts
  747. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/acerts
  748. cp ${TEST_KEY} ${TEST}/hosts/moon/${IPSEC_DIR}/private
  749. cp ${TEST_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/aacerts
  750. # Generate carol's expired attribute certificate for finance
  751. ACERT=${TEST}/hosts/carol/${IPSEC_DIR}/acerts/carol-finance-expired.pem
  752. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/acerts
  753. pki --acert --issuerkey ${TEST_KEY} --issuercert ${TEST_CERT} \
  754. --in ${CA_DIR}/certs/01.pem --group finance \
  755. --not-before "${START}" --not-after "${SH_END}" --outform pem > ${ACERT}
  756. # Generate carol's valid attribute certificate for sales
  757. ACERT_CS=${TEST}/hosts/carol/${IPSEC_DIR}/acerts/carol-sales.pem
  758. pki --acert --issuerkey ${TEST_KEY} --issuercert ${TEST_CERT} \
  759. --in ${CA_DIR}/certs/01.pem --group sales \
  760. --not-before "${SH_END}" --not-after "${EE_END}" --outform pem > ${ACERT_CS}
  761. # Put a copy into the ikev2/acert-inline scenario
  762. TEST="${TEST_DIR}/ikev2/acert-inline"
  763. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  764. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/aacerts
  765. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/acerts
  766. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/acerts
  767. cp ${TEST_KEY} ${TEST}/hosts/moon/${IPSEC_DIR}/private
  768. cp ${TEST_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/aacerts
  769. cp ${ACERT_CS} ${TEST}/hosts/carol/${IPSEC_DIR}/acerts
  770. cp ${ACERT_DM} ${TEST}/hosts/dave/${IPSEC_DIR}/acerts
  771. # Generate a short-lived Attritbute Authority certificate
  772. CN="strongSwan Legacy AA"
  773. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/aaKey-expired.pem"
  774. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/aacerts/aaCert-expired.pem"
  775. SERIAL="18"
  776. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  777. pki --issue --cakey ${CA_KEY} --cacert ${CA_CERT} --crl ${CA_CDP} --type rsa \
  778. --in ${TEST_KEY} --not-before "${START}" --not-after "${SH_END}" \
  779. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, CN=${CN}" \
  780. --outform pem > ${TEST_CERT}
  781. cp ${TEST_CERT} ${CA_DIR}/certs/${SERIAL}.pem
  782. # Generate dave's attribute certificate for sales from expired AA
  783. ACERT=${TEST}/hosts/dave/${IPSEC_DIR}/acerts/dave-expired-aa.pem
  784. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/acerts
  785. pki --acert --issuerkey ${TEST_KEY} --issuercert ${TEST_CERT} \
  786. --in ${CA_DIR}/certs/02.pem --group sales \
  787. --not-before "${START}" --not-after "${EE_END}" --outform pem > ${ACERT}
  788. ################################################################################
  789. # strongSwan Root CA index for OCSP server #
  790. ################################################################################
  791. # generate index.txt file for Root OCSP server
  792. cp ${CA_DIR}/index.txt.template ${CA_DIR}/index.txt
  793. sed -i -e "s/EE_EXPIRATION/${EE_EXP}/g" ${CA_DIR}/index.txt
  794. sed -i -e "s/IM_EXPIRATION/${IM_EXP}/g" ${CA_DIR}/index.txt
  795. sed -i -e "s/SH_EXPIRATION/${SH_EXP}/g" ${CA_DIR}/index.txt
  796. sed -i -e "s/REVOCATION/${NOW}/g" ${CA_DIR}/index.txt
  797. ################################################################################
  798. # Research CA #
  799. ################################################################################
  800. # Generate a carol research certificate
  801. TEST="${TEST_DIR}/ikev2/multi-level-ca"
  802. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey.pem"
  803. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert.pem"
  804. CN="carol@strongswan.org"
  805. SERIAL="01"
  806. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  807. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  808. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  809. pki --issue --cakey ${RESEARCH_KEY} --cacert ${RESEARCH_CERT} --type rsa \
  810. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  811. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=${CN}" \
  812. --crl ${RESEARCH_CDP} --outform pem > ${TEST_CERT}
  813. cp ${TEST_CERT} ${RESEARCH_DIR}/certs/${SERIAL}.pem
  814. # Save a copy of the private key in DER format
  815. openssl rsa -in ${TEST_KEY} -outform der \
  816. -out ${RESEARCH_DIR}/keys/${SERIAL}.der 2> /dev/null
  817. # Put a copy in the following scenarios
  818. for t in ikev2/multi-level-ca-cr-init ikev2/multi-level-ca-cr-resp \
  819. ikev2/multi-level-ca-ldap ikev2/multi-level-ca-loop \
  820. ikev2/multi-level-ca-revoked ikev2/multi-level-ca-skipped \
  821. ikev2/multi-level-ca-strict ikev2/ocsp-multi-level \
  822. ikev1/multi-level-ca ikev1/multi-level-ca-cr-init \
  823. ikev1/multi-level-ca-cr-resp
  824. do
  825. TEST="${TEST_DIR}/${t}"
  826. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  827. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  828. cp ${TEST_KEY} ${TEST}/hosts/carol/${IPSEC_DIR}/private
  829. cp ${TEST_CERT} ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  830. done
  831. for t in multi-level-ca ocsp-multi-level
  832. do
  833. TEST="${TEST_DIR}/swanctl/${t}"
  834. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/rsa
  835. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  836. cp ${TEST_KEY} ${TEST}/hosts/carol/${SWANCTL_DIR}/rsa
  837. cp ${TEST_CERT} ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  838. done
  839. # Generate a carol research certificate without a CDP
  840. TEST="${TEST_DIR}/ikev2/ocsp-strict-ifuri"
  841. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert.pem"
  842. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  843. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  844. pki --issue --cakey ${RESEARCH_KEY} --cacert ${RESEARCH_CERT} --type rsa \
  845. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  846. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=${CN}" \
  847. --outform pem > ${TEST_CERT}
  848. cp ${TEST_KEY} ${TEST}/hosts/carol/${IPSEC_DIR}/private
  849. # Generate an OCSP Signing certificate for the Research CA
  850. TEST_KEY="${RESEARCH_DIR}/ocspKey.pem"
  851. TEST_CERT="${RESEARCH_DIR}/ocspCert.pem"
  852. OU="Research OCSP Signing Authority"
  853. CN="ocsp.research.strongswan.org"
  854. SERIAL="02"
  855. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  856. pki --issue --cakey ${RESEARCH_KEY} --cacert ${RESEARCH_CERT} --type rsa \
  857. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  858. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=${OU}, CN=${CN}" \
  859. --crl ${RESEARCH_CDP} --flag ocspSigning --outform pem > ${TEST_CERT}
  860. cp ${TEST_CERT} ${RESEARCH_DIR}/certs/${SERIAL}.pem
  861. # Generate a Sales CA certificate signed by the Research CA
  862. TEST="${TEST_DIR}/ikev2/multi-level-ca-loop"
  863. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/cacerts/sales_by_researchCert.pem"
  864. SERIAL="03"
  865. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  866. pki --issue --cakey ${RESEARCH_KEY} --cacert ${RESEARCH_CERT} --type rsa \
  867. --in ${SALES_KEY} --not-before "${START}" --not-after "${EE_END}" --ca \
  868. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Sales, CN=Sales CA" \
  869. --crl ${RESEARCH_CDP} --outform pem > ${TEST_CERT}
  870. cp ${TEST_CERT} ${RESEARCH_DIR}/certs/${SERIAL}.pem
  871. ################################################################################
  872. # Duck Research CA #
  873. ################################################################################
  874. # Generate a Duck Research CA certificate signed by the Research CA
  875. SERIAL="04"
  876. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${DUCK_KEY}
  877. pki --issue --cakey ${RESEARCH_KEY} --cacert ${RESEARCH_CERT} --type rsa \
  878. --in ${DUCK_KEY} --not-before "${START}" --not-after "${EE_END}" --ca \
  879. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=Duck Research CA" \
  880. --crl ${RESEARCH_CDP} --outform pem > ${DUCK_CERT}
  881. cp ${DUCK_CERT} ${RESEARCH_DIR}/certs/${SERIAL}.pem
  882. # Put a certificate copy in the ikev2/multilevel-ca-pathlen scenario
  883. TEST="${TEST_DIR}/ikev2/multi-level-ca-pathlen"
  884. cp ${DUCK_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  885. # Generate a carol certificate signed by the Duck Research CA
  886. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey.pem"
  887. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert.pem"
  888. CN="carol@strongswan.org"
  889. SERIAL="01"
  890. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  891. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  892. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  893. pki --issue --cakey ${DUCK_KEY} --cacert ${DUCK_CERT} --type rsa \
  894. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  895. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Duck Research, CN=${CN}" \
  896. --outform pem > ${TEST_CERT}
  897. cp ${TEST_CERT} ${DUCK_DIR}/certs/${SERIAL}.pem
  898. # Generate index.txt file for Research OCSP server
  899. cp ${RESEARCH_DIR}/index.txt.template ${RESEARCH_DIR}/index.txt
  900. sed -i -e "s/EE_EXPIRATION/${EE_EXP}/g" ${RESEARCH_DIR}/index.txt
  901. ################################################################################
  902. # Sales CA #
  903. ################################################################################
  904. # Generate a dave sales certificate
  905. TEST="${TEST_DIR}/ikev2/multi-level-ca"
  906. TEST_KEY="${TEST}/hosts/dave/${IPSEC_DIR}/private/daveKey.pem"
  907. TEST_CERT="${TEST}/hosts/dave/${IPSEC_DIR}/certs/daveCert.pem"
  908. CN="dave@strongswan.org"
  909. SERIAL="01"
  910. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  911. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  912. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  913. pki --issue --cakey ${SALES_KEY} --cacert ${SALES_CERT} --type rsa \
  914. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  915. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Sales, CN=${CN}" \
  916. --crl ${SALES_CDP} --outform pem > ${TEST_CERT}
  917. cp ${TEST_CERT} ${SALES_DIR}/certs/${SERIAL}.pem
  918. # Save a copy of the private key in DER format
  919. openssl rsa -in ${TEST_KEY} -outform der \
  920. -out ${SALES_DIR}/keys/${SERIAL}.der 2> /dev/null
  921. # Put a copy in the following scenarios
  922. for t in ikev2/multi-level-ca-cr-init ikev2/multi-level-ca-cr-resp \
  923. ikev2/multi-level-ca-ldap ikev2/multi-level-ca-strict \
  924. ikev2/ocsp-multi-level ikev1/multi-level-ca \
  925. ikev1/multi-level-ca-cr-init ikev1/multi-level-ca-cr-resp
  926. do
  927. TEST="${TEST_DIR}/${t}"
  928. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  929. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  930. cp ${TEST_KEY} ${TEST}/hosts/dave/${IPSEC_DIR}/private
  931. cp ${TEST_CERT} ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  932. done
  933. for t in multi-level-ca ocsp-multi-level
  934. do
  935. TEST="${TEST_DIR}/swanctl/${t}"
  936. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/rsa
  937. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  938. cp ${TEST_KEY} ${TEST}/hosts/dave/${SWANCTL_DIR}/rsa
  939. cp ${TEST_CERT} ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  940. done
  941. # Generate a dave sales certificate with an inactive OCSP URI and no CDP
  942. TEST="${TEST_DIR}/ikev2/ocsp-strict-ifuri"
  943. TEST_CERT="${TEST}/hosts/dave/${IPSEC_DIR}/certs/daveCert.pem"
  944. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  945. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  946. pki --issue --cakey ${SALES_KEY} --cacert ${SALES_CERT} --type rsa \
  947. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  948. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Sales, CN=${CN}" \
  949. --ocsp "http://ocsp2.strongswan.org:8882" --outform pem > ${TEST_CERT}
  950. cp ${TEST_KEY} ${TEST}/hosts/dave/${IPSEC_DIR}/private
  951. # Generate an OCSP Signing certificate for the Sales CA
  952. TEST_KEY="${SALES_DIR}/ocspKey.pem"
  953. TEST_CERT="${SALES_DIR}/ocspCert.pem"
  954. OU="Sales OCSP Signing Authority"
  955. CN="ocsp.sales.strongswan.org"
  956. SERIAL="02"
  957. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  958. pki --issue --cakey ${SALES_KEY} --cacert ${SALES_CERT} --type rsa \
  959. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  960. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=${OU}, CN=${CN}" \
  961. --crl ${SALES_CDP} --flag ocspSigning --outform pem > ${TEST_CERT}
  962. cp ${TEST_CERT} ${SALES_DIR}/certs/${SERIAL}.pem
  963. # Generate a Research CA certificate signed by the Sales CA
  964. TEST="${TEST_DIR}/ikev2/multi-level-ca-loop"
  965. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/cacerts/research_by_salesCert.pem"
  966. SERIAL="03"
  967. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  968. pki --issue --cakey ${SALES_KEY} --cacert ${SALES_CERT} --type rsa \
  969. --in ${RESEARCH_KEY} --not-before "${START}" --not-after "${EE_END}" --ca \
  970. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Research, CN=Research CA" \
  971. --crl ${SALES_CDP} --outform pem > ${TEST_CERT}
  972. cp ${TEST_CERT} ${SALES_DIR}/certs/${SERIAL}.pem
  973. # generate index.txt file for Sales OCSP server
  974. cp ${SALES_DIR}/index.txt.template ${SALES_DIR}/index.txt
  975. sed -i -e "s/EE_EXPIRATION/${EE_EXP}/g" ${SALES_DIR}/index.txt
  976. ################################################################################
  977. # strongSwan EC Root CA #
  978. ################################################################################
  979. # Generate strongSwan EC Root CA
  980. pki --gen --type ecdsa --size 521 --outform pem > ${ECDSA_KEY}
  981. pki --self --type ecdsa --in ${ECDSA_KEY} \
  982. --not-before "${START}" --not-after "${CA_END}" --ca \
  983. --dn "C=CH, O=${PROJECT}, CN=strongSwan EC Root CA" \
  984. --outform pem > ${ECDSA_CERT}
  985. # Put a copy in the openssl-ikev2/ecdsa-certs scenario
  986. for t in ecdsa-certs ecdsa-pkcs8
  987. do
  988. TEST="${TEST_DIR}/openssl-ikev2/${t}"
  989. for h in moon carol dave
  990. do
  991. mkdir -p ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  992. cp ${ECDSA_CERT} ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  993. done
  994. done
  995. # Generate a moon ECDSA 521 bit certificate
  996. TEST="${TEST_DIR}/openssl-ikev2/ecdsa-certs"
  997. MOON_KEY="${TEST}/hosts/moon/${SWANCTL_DIR}/ecdsa/moonKey.pem"
  998. MOON_CERT="${TEST}/hosts/moon/${SWANCTL_DIR}/x509/moonCert.pem"
  999. CN="moon.strongswan.org"
  1000. SERIAL="01"
  1001. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/ecdsa
  1002. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1003. pki --gen --type ecdsa --size 521 --outform pem > ${MOON_KEY}
  1004. pki --issue --cakey ${ECDSA_KEY} --cacert ${ECDSA_CERT} --type ecdsa \
  1005. --in ${MOON_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1006. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=ECDSA 512 bit, CN=${CN}" \
  1007. --crl ${ECDSA_CDP} --outform pem > ${MOON_CERT}
  1008. cp ${MOON_CERT} ${ECDSA_DIR}/certs/${SERIAL}.pem
  1009. # Generate a carol ECDSA 256 bit certificate
  1010. CAROL_KEY="${TEST}/hosts/carol/${SWANCTL_DIR}/ecdsa/carolKey.pem"
  1011. CAROL_CERT="${TEST}/hosts/carol/${SWANCTL_DIR}/x509/carolCert.pem"
  1012. CN="carol@strongswan.org"
  1013. SERIAL="02"
  1014. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/ecdsa
  1015. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1016. pki --gen --type ecdsa --size 256 --outform pem > ${CAROL_KEY}
  1017. pki --issue --cakey ${ECDSA_KEY} --cacert ${ECDSA_CERT} --type ecdsa \
  1018. --in ${CAROL_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1019. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=ECDSA 256 bit, CN=${CN}" \
  1020. --crl ${ECDSA_CDP} --outform pem > ${CAROL_CERT}
  1021. cp ${CAROL_CERT} ${ECDSA_DIR}/certs/${SERIAL}.pem
  1022. # Generate a dave ECDSA 384 bit certificate
  1023. DAVE_KEY="${TEST}/hosts/dave/${SWANCTL_DIR}/ecdsa/daveKey.pem"
  1024. DAVE_CERT="${TEST}/hosts/dave/${SWANCTL_DIR}/x509/daveCert.pem"
  1025. CN="dave@strongswan.org"
  1026. SERIAL="03"
  1027. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/ecdsa
  1028. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  1029. pki --gen --type ecdsa --size 384 --outform pem > ${DAVE_KEY}
  1030. pki --issue --cakey ${ECDSA_KEY} --cacert ${ECDSA_CERT} --type ecdsa \
  1031. --in ${DAVE_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1032. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=ECDSA 384 bit, CN=${CN}" \
  1033. --crl ${ECDSA_CDP} --outform pem > ${DAVE_CERT}
  1034. cp ${DAVE_CERT} ${ECDSA_DIR}/certs/${SERIAL}.pem
  1035. # Put CA and EE certificate copies in the openssl-ikev2/ecdsa-pkcs8 scenario
  1036. TEST="${TEST_DIR}/openssl-ikev2/ecdsa-pkcs8"
  1037. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1038. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1039. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  1040. cp ${MOON_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1041. cp ${CAROL_CERT} ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1042. cp ${DAVE_CERT} ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  1043. # Convert moon private key into unencrypted PKCS#8 format
  1044. TEST_KEY="${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs8/moonKey.pem"
  1045. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs8
  1046. openssl pkcs8 -in ${MOON_KEY} -nocrypt -topk8 -out ${TEST_KEY}
  1047. # Convert carol private key into v1.5 DES encrypted PKCS#8 format
  1048. TEST_KEY="${TEST}/hosts/carol/${SWANCTL_DIR}/pkcs8/carolKey.pem"
  1049. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/pkcs8
  1050. openssl pkcs8 -in ${CAROL_KEY} -nocrypt -topk8 -v1 PBE-MD5-DES \
  1051. -passout "pass:nH5ZQEWtku0RJEZ6" -out ${TEST_KEY}
  1052. # Convert dave private key into v2.0 AES-128 encrypted PKCS#8 format
  1053. TEST_KEY="${TEST}/hosts/dave/${SWANCTL_DIR}/pkcs8/daveKey.pem"
  1054. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/pkcs8
  1055. openssl pkcs8 -in ${DAVE_KEY} -nocrypt -topk8 -v2 aes128 \
  1056. -passout "pass:OJlNZBx+80dLh4wC6fw5LmBd" -out ${TEST_KEY}
  1057. # Put CA and EE certificate copies in the openssl-ikev1/ecdsa-certs scenario
  1058. TEST="${TEST_DIR}/openssl-ikev1/ecdsa-certs"
  1059. cd ${TEST}/hosts/moon/${SWANCTL_DIR}
  1060. mkdir -p ecdsa x509 x509ca
  1061. cp ${MOON_KEY} ecdsa
  1062. cp ${MOON_CERT} x509
  1063. cp ${ECDSA_CERT} x509ca
  1064. cd ${TEST}/hosts/carol/${SWANCTL_DIR}
  1065. mkdir -p ecdsa x509 x509ca
  1066. cp ${CAROL_KEY} ecdsa
  1067. cp ${CAROL_CERT} x509
  1068. cp ${ECDSA_CERT} x509ca
  1069. cd ${TEST}/hosts/dave/${SWANCTL_DIR}
  1070. mkdir -p ecdsa x509 x509ca
  1071. cp ${DAVE_KEY} ecdsa
  1072. cp ${DAVE_CERT} x509
  1073. cp ${ECDSA_CERT} x509ca
  1074. ################################################################################
  1075. # strongSwan RFC3779 Root CA #
  1076. ################################################################################
  1077. # Generate strongSwan RFC3779 Root CA
  1078. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${RFC3779_KEY}
  1079. pki --self --type rsa --in ${RFC3779_KEY} \
  1080. --not-before "${START}" --not-after "${CA_END}" --ca \
  1081. --dn "C=CH, O=${PROJECT}, OU=RFC3779, CN=strongSwan RFC3779 Root CA" \
  1082. --addrblock "10.1.0.0-10.2.255.255" \
  1083. --addrblock "10.3.0.1-10.3.3.232" \
  1084. --addrblock "192.168.0.0/24" \
  1085. --addrblock "fec0::-fec2:ffff:ffff:ffff:ffff:ffff:ffff:ffff" \
  1086. --outform pem > ${RFC3779_CERT}
  1087. # Put a copy in the ikev2/net2net-rfc3779 scenario
  1088. TEST="${TEST_DIR}/ikev2/net2net-rfc3779"
  1089. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  1090. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/cacerts
  1091. cp ${RFC3779_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  1092. cp ${RFC3779_CERT} ${TEST}/hosts/sun/${IPSEC_DIR}/cacerts
  1093. # Put a copy in the ipv6/rw-rfc3779-ikev2 scenario
  1094. TEST="${TEST_DIR}/ipv6/rw-rfc3779-ikev2"
  1095. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509ca
  1096. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509ca
  1097. cp ${RFC3779_CERT} ${TEST}/hosts/carol/${SWANCTL_DIR}/x509ca
  1098. cp ${RFC3779_CERT} ${TEST}/hosts/dave/${SWANCTL_DIR}/x509ca
  1099. # Generate a moon RFC3779 certificate
  1100. TEST="${TEST_DIR}/ikev2/net2net-rfc3779"
  1101. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/moonKey.pem"
  1102. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/certs/moonCert.pem"
  1103. CN="moon.strongswan.org"
  1104. SERIAL="01"
  1105. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  1106. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  1107. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  1108. pki --issue --cakey ${RFC3779_KEY} --cacert ${RFC3779_CERT} --type rsa \
  1109. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1110. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=RFC3779, CN=${CN}" \
  1111. --addrblock "10.1.0.0/16" --addrblock "192.168.0.1/32" \
  1112. --addrblock "fec0::1/128" --addrblock "fec1::/16" \
  1113. --crl ${RFC3779_CDP} --outform pem > ${TEST_CERT}
  1114. cp ${TEST_CERT} ${RFC3779_DIR}/certs/${SERIAL}.pem
  1115. # Put a copy in the ipv6 scenarios
  1116. for t in net2net-rfc3779-ikev2 rw-rfc3779-ikev2
  1117. do
  1118. cd "${TEST_DIR}/ipv6/${t}/hosts/moon/${SWANCTL_DIR}"
  1119. mkdir -p rsa x509 x509ca
  1120. cp ${TEST_KEY} rsa
  1121. cp ${TEST_CERT} x509
  1122. cp ${RFC3779_CERT} x509ca
  1123. done
  1124. # Generate a sun RFC3779 certificate
  1125. TEST="${TEST_DIR}/ikev2/net2net-rfc3779"
  1126. TEST_KEY="${TEST}/hosts/sun/${IPSEC_DIR}/private/sunKey.pem"
  1127. TEST_CERT="${TEST}/hosts/sun/${IPSEC_DIR}/certs/sunCert.pem"
  1128. CN="sun.strongswan.org"
  1129. SERIAL="02"
  1130. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/private
  1131. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}/certs
  1132. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  1133. pki --issue --cakey ${RFC3779_KEY} --cacert ${RFC3779_CERT} --type rsa \
  1134. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1135. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=RFC3779, CN=${CN}" \
  1136. --addrblock "10.2.0.0/16" --addrblock "192.168.0.2/32" \
  1137. --addrblock "fec0::2/128" --addrblock "fec2::/16" \
  1138. --crl ${RFC3779_CDP} --outform pem > ${TEST_CERT}
  1139. cp ${TEST_CERT} ${RFC3779_DIR}/certs/${SERIAL}.pem
  1140. # Put a copy in the ipv6/net2net-rfc3779-ikev2 scenario
  1141. cd "${TEST_DIR}/ipv6/net2net-rfc3779-ikev2/hosts/sun/${SWANCTL_DIR}"
  1142. mkdir -p rsa x509 x509ca
  1143. cp ${TEST_KEY} rsa
  1144. cp ${TEST_CERT} x509
  1145. cp ${RFC3779_CERT} x509ca
  1146. # Generate a carol RFC3779 certificate
  1147. TEST="${TEST_DIR}/ipv6/rw-rfc3779-ikev2"
  1148. TEST_KEY="${TEST}/hosts/carol/${SWANCTL_DIR}/rsa/carolKey.pem"
  1149. TEST_CERT="${TEST}/hosts/carol/${SWANCTL_DIR}/x509/carolCert.pem"
  1150. CN="carol@strongswan.org"
  1151. SERIAL="03"
  1152. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/rsa
  1153. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1154. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  1155. pki --issue --cakey ${RFC3779_KEY} --cacert ${RFC3779_CERT} --type rsa \
  1156. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1157. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=RFC3779, CN=${CN}" \
  1158. --addrblock "10.3.0.1/32" --addrblock "192.168.0.100/32" \
  1159. --addrblock "fec0::10/128" \
  1160. --crl ${RFC3779_CDP} --outform pem > ${TEST_CERT}
  1161. cp ${TEST_CERT} ${RFC3779_DIR}/certs/${SERIAL}.pem
  1162. # Generate a carol RFC3779 certificate
  1163. TEST="${TEST_DIR}/ipv6/rw-rfc3779-ikev2"
  1164. TEST_KEY="${TEST}/hosts/dave/${SWANCTL_DIR}/rsa/daveKey.pem"
  1165. TEST_CERT="${TEST}/hosts/dave/${SWANCTL_DIR}/x509/daveCert.pem"
  1166. CN="dave@strongswan.org"
  1167. SERIAL="04"
  1168. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/rsa
  1169. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  1170. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  1171. pki --issue --cakey ${RFC3779_KEY} --cacert ${RFC3779_CERT} --type rsa \
  1172. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1173. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=RFC3779, CN=${CN}" \
  1174. --addrblock "10.3.0.2/32" --addrblock "192.168.0.200/32" \
  1175. --addrblock "fec0::20/128" \
  1176. --crl ${RFC3779_CDP} --outform pem > ${TEST_CERT}
  1177. cp ${TEST_CERT} ${RFC3779_DIR}/certs/${SERIAL}.pem
  1178. ################################################################################
  1179. # strongSwan SHA3-RSA Root CA #
  1180. ################################################################################
  1181. # Use specific plugin configuration to issue certificates with SHA-3 signatures
  1182. # as not all crypto plugins support them. To avoid entropy issues use the
  1183. # default plugins to generate the keys.
  1184. SHA3_PKI_PLUGINS="gmp pem pkcs1 random sha1 sha3 x509"
  1185. # Generate strongSwan SHA3-RSA Root CA
  1186. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${SHA3_RSA_KEY}
  1187. PKI_PLUGINS="${SHA3_PKI_PLUGINS}" \
  1188. pki --self --type rsa --in ${SHA3_RSA_KEY} --digest sha3_256 \
  1189. --not-before "${START}" --not-after "${CA_END}" --ca \
  1190. --dn "C=CH, O=${PROJECT}, OU=SHA-3, CN=strongSwan Root CA" \
  1191. --outform pem > ${SHA3_RSA_CERT}
  1192. # Put a copy in the swanctl/net2net-sha3-rsa-cert scenario
  1193. TEST="${TEST_DIR}/swanctl/net2net-sha3-rsa-cert"
  1194. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509ca
  1195. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/x509ca
  1196. cp ${SHA3_RSA_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509ca
  1197. cp ${SHA3_RSA_CERT} ${TEST}/hosts/sun/${SWANCTL_DIR}/x509ca
  1198. # Generate a sun SHA3-RSA certificate
  1199. SUN_KEY="${TEST}/hosts/sun/${SWANCTL_DIR}/rsa/sunKey.pem"
  1200. SUN_CERT="${TEST}/hosts/sun/${SWANCTL_DIR}/x509/sunCert.pem"
  1201. CN="sun.strongswan.org"
  1202. SERIAL="01"
  1203. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/rsa
  1204. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/x509
  1205. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${SUN_KEY}
  1206. PKI_PLUGINS="${SHA3_PKI_PLUGINS}" \
  1207. pki --issue --cakey ${SHA3_RSA_KEY} --cacert ${SHA3_RSA_CERT} --type rsa \
  1208. --in ${SUN_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1209. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=SHA-3, CN=${CN}" \
  1210. --crl ${SHA3_RSA_CDP} --digest sha3_256 --outform pem > ${SUN_CERT}
  1211. cp ${SUN_CERT} ${SHA3_RSA_DIR}/certs/${SERIAL}.pem
  1212. # Generate a moon SHA3-RSA certificate
  1213. MOON_KEY="${TEST}/hosts/moon/${SWANCTL_DIR}/rsa/moonKey.pem"
  1214. MOON_CERT="${TEST}/hosts/moon/${SWANCTL_DIR}/x509/moonCert.pem"
  1215. CN="moon.strongswan.org"
  1216. SERIAL="02"
  1217. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/rsa
  1218. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1219. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${MOON_KEY}
  1220. PKI_PLUGINS="${SHA3_PKI_PLUGINS}" \
  1221. pki --issue --cakey ${SHA3_RSA_KEY} --cacert ${SHA3_RSA_CERT} --type rsa \
  1222. --in ${MOON_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1223. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=SHA-3, CN=${CN}" \
  1224. --crl ${SHA3_RSA_CDP} --digest sha3_256 --outform pem > ${MOON_CERT}
  1225. cp ${MOON_CERT} ${SHA3_RSA_DIR}/certs/${SERIAL}.pem
  1226. # Put a copy in the botan/net2net-sha3-rsa-cert scenario
  1227. TEST="${TEST_DIR}/botan/net2net-sha3-rsa-cert"
  1228. cd ${TEST}/hosts/moon/${SWANCTL_DIR}
  1229. mkdir -p rsa x509 x509ca
  1230. cp ${MOON_KEY} rsa
  1231. cp ${MOON_CERT} x509
  1232. cp ${SHA3_RSA_CERT} x509ca
  1233. cd ${TEST}/hosts/sun/${SWANCTL_DIR}
  1234. mkdir -p rsa x509 x509ca
  1235. cp ${SUN_KEY} rsa
  1236. cp ${SUN_CERT} x509
  1237. cp ${SHA3_RSA_CERT} x509ca
  1238. # Put a copy in the swanctl/rw-eap-tls-sha3-rsa scenario
  1239. TEST="${TEST_DIR}/swanctl/rw-eap-tls-sha3-rsa"
  1240. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/rsa
  1241. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1242. cp ${MOON_KEY} ${TEST}/hosts/moon/${SWANCTL_DIR}/rsa
  1243. cp ${MOON_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1244. # Generate a carol SHA3-RSA certificate
  1245. TEST_KEY="${TEST}/hosts/carol/${SWANCTL_DIR}/rsa/carolKey.pem"
  1246. TEST_CERT="${TEST}/hosts/carol/${SWANCTL_DIR}/x509/carolCert.pem"
  1247. CN="carol@strongswan.org"
  1248. SERIAL="03"
  1249. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/rsa
  1250. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1251. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  1252. PKI_PLUGINS="${SHA3_PKI_PLUGINS}" \
  1253. pki --issue --cakey ${SHA3_RSA_KEY} --cacert ${SHA3_RSA_CERT} --type rsa \
  1254. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1255. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=SHA-3, CN=${CN}" \
  1256. --crl ${SHA3_RSA_CDP} --digest sha3_256 --outform pem > ${TEST_CERT}
  1257. cp ${TEST_CERT} ${SHA3_RSA_DIR}/certs/${SERIAL}.pem
  1258. # Generate a dave SHA3-RSA certificate
  1259. TEST_KEY="${TEST}/hosts/dave/${SWANCTL_DIR}/rsa/daveKey.pem"
  1260. TEST_CERT="${TEST}/hosts/dave/${SWANCTL_DIR}/x509/daveCert.pem"
  1261. CN="dave@strongswan.org"
  1262. SERIAL="04"
  1263. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/rsa
  1264. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  1265. pki --gen --type rsa --size ${RSA_SIZE} --outform pem > ${TEST_KEY}
  1266. PKI_PLUGINS="${SHA3_PKI_PLUGINS}" \
  1267. pki --issue --cakey ${SHA3_RSA_KEY} --cacert ${SHA3_RSA_CERT} --type rsa \
  1268. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1269. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=SHA-3, CN=${CN}" \
  1270. --crl ${SHA3_RSA_CDP} --digest sha3_256 --outform pem > ${TEST_CERT}
  1271. cp ${TEST_CERT} ${SHA3_RSA_DIR}/certs/${SERIAL}.pem
  1272. for h in moon carol dave
  1273. do
  1274. mkdir -p ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  1275. cp ${SHA3_RSA_CERT} ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  1276. done
  1277. ################################################################################
  1278. # strongSwan Ed25519 Root CA #
  1279. ################################################################################
  1280. # Generate strongSwan Ed25519 Root CA
  1281. pki --gen --type ed25519 --outform pem > ${ED25519_KEY}
  1282. pki --self --type ed25519 --in ${ED25519_KEY} \
  1283. --not-before "${START}" --not-after "${CA_END}" --ca \
  1284. --dn "C=CH, O=${PROJECT}, CN=strongSwan Ed25519 Root CA" \
  1285. --cert-policy "1.3.6.1.4.1.36906.1.1.1" \
  1286. --cert-policy "1.3.6.1.4.1.36906.1.1.2" \
  1287. --outform pem > ${ED25519_CERT}
  1288. # Put a copy in the swanctl/net2net-ed25519 scenario
  1289. TEST="${TEST_DIR}/swanctl/net2net-ed25519"
  1290. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509ca
  1291. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/x509ca
  1292. cp ${ED25519_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509ca
  1293. cp ${ED25519_CERT} ${TEST}/hosts/sun/${SWANCTL_DIR}/x509ca
  1294. # Generate a sun Ed25519 certificate
  1295. SUN_KEY="${TEST}/hosts/sun/${SWANCTL_DIR}/pkcs8/sunKey.pem"
  1296. SUN_CERT="${TEST}/hosts/sun/${SWANCTL_DIR}/x509/sunCert.pem"
  1297. CN="sun.strongswan.org"
  1298. SERIAL="01"
  1299. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/pkcs8
  1300. mkdir -p ${TEST}/hosts/sun/${SWANCTL_DIR}/x509
  1301. pki --gen --type ed25519 --outform pem > ${SUN_KEY}
  1302. pki --issue --cakey ${ED25519_KEY} --cacert ${ED25519_CERT} --type ed25519 \
  1303. --in ${SUN_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1304. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Ed25519, CN=${CN}" \
  1305. --cert-policy "1.3.6.1.4.1.36906.1.1.2" --flag "serverAuth" \
  1306. --crl ${ED25519_CDP} --outform pem > ${SUN_CERT}
  1307. cp ${SUN_CERT} ${ED25519_DIR}/certs/${SERIAL}.pem
  1308. # Generate a moon Ed25519 certificate
  1309. MOON_KEY="${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs8/moonKey.pem"
  1310. MOON_CERT="${TEST}/hosts/moon/${SWANCTL_DIR}/x509/moonCert.pem"
  1311. CN="moon.strongswan.org"
  1312. SERIAL="02"
  1313. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs8
  1314. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1315. pki --gen --type ed25519 --outform pem > ${MOON_KEY}
  1316. pki --issue --cakey ${ED25519_KEY} --cacert ${ED25519_CERT} --type ed25519 \
  1317. --in ${MOON_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1318. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Ed25519, CN=${CN}" \
  1319. --cert-policy "1.3.6.1.4.1.36906.1.1.1" --flag "serverAuth" \
  1320. --crl ${ED25519_CDP} --outform pem > ${MOON_CERT}
  1321. cp ${MOON_CERT} ${ED25519_DIR}/certs/${SERIAL}.pem
  1322. # Put a copy in the botan/net2net-ed25519 scenario
  1323. TEST="${TEST_DIR}/botan/net2net-ed25519"
  1324. cd ${TEST}/hosts/moon/${SWANCTL_DIR}
  1325. mkdir -p pkcs8 x509 x509ca
  1326. cp ${MOON_KEY} pkcs8
  1327. cp ${MOON_CERT} x509
  1328. cp ${ED25519_CERT} x509ca
  1329. cd ${TEST}/hosts/sun/${SWANCTL_DIR}
  1330. mkdir -p pkcs8 x509 x509ca
  1331. cp ${SUN_KEY} pkcs8
  1332. cp ${SUN_CERT} x509
  1333. cp ${ED25519_CERT} x509ca
  1334. # Put a copy in the ikev2/net2net-ed25519 scenario
  1335. TEST="${TEST_DIR}/ikev2/net2net-ed25519"
  1336. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}
  1337. cd ${TEST}/hosts/moon/${IPSEC_DIR}
  1338. mkdir -p cacerts certs private
  1339. cp ${MOON_KEY} private
  1340. cp ${MOON_CERT} certs
  1341. cp ${ED25519_CERT} cacerts
  1342. mkdir -p ${TEST}/hosts/sun/${IPSEC_DIR}
  1343. cd ${TEST}/hosts/sun/${IPSEC_DIR}
  1344. mkdir -p cacerts certs private
  1345. cp ${SUN_KEY} private
  1346. cp ${SUN_CERT} certs
  1347. cp ${ED25519_CERT} cacerts
  1348. # Put a copy in the swanctl/rw-ed25519-certpol scenario
  1349. TEST="${TEST_DIR}/swanctl/rw-ed25519-certpol"
  1350. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs8
  1351. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1352. cp ${MOON_KEY} ${TEST}/hosts/moon/${SWANCTL_DIR}/pkcs8
  1353. cp ${MOON_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1354. for h in moon carol dave
  1355. do
  1356. mkdir -p ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  1357. cp ${ED25519_CERT} ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  1358. done
  1359. # Generate a carol Ed25519 certificate
  1360. TEST_KEY="${TEST}/hosts/carol/${SWANCTL_DIR}/pkcs8/carolKey.pem"
  1361. TEST_CERT="${TEST}/hosts/carol/${SWANCTL_DIR}/x509/carolCert.pem"
  1362. CN="carol@strongswan.org"
  1363. SERIAL="03"
  1364. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/pkcs8
  1365. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1366. pki --gen --type ed25519 --outform pem > ${TEST_KEY}
  1367. pki --issue --cakey ${ED25519_KEY} --cacert ${ED25519_CERT} --type ed25519 \
  1368. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1369. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Ed25519, CN=${CN}" \
  1370. --cert-policy "1.3.6.1.4.1.36906.1.1.1" --flag "clientAuth" \
  1371. --crl ${ED25519_CDP} --outform pem > ${TEST_CERT}
  1372. cp ${TEST_CERT} ${ED25519_DIR}/certs/${SERIAL}.pem
  1373. # Generate a dave Ed25519 certificate
  1374. TEST_KEY="${TEST}/hosts/dave/${SWANCTL_DIR}/pkcs8/daveKey.pem"
  1375. TEST_CERT="${TEST}/hosts/dave/${SWANCTL_DIR}/x509/daveCert.pem"
  1376. CN="dave@strongswan.org"
  1377. SERIAL="04"
  1378. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/pkcs8
  1379. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  1380. pki --gen --type ed25519 --outform pem > ${TEST_KEY}
  1381. pki --issue --cakey ${ED25519_KEY} --cacert ${ED25519_CERT} --type ed25519 \
  1382. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1383. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Ed25519, CN=${CN}" \
  1384. --cert-policy "1.3.6.1.4.1.36906.1.1.2" --flag "clientAuth" \
  1385. --crl ${ED25519_CDP} --outform pem > ${TEST_CERT}
  1386. cp ${TEST_CERT} ${ED25519_DIR}/certs/${SERIAL}.pem
  1387. ################################################################################
  1388. # strongSwan Monster Root CA #
  1389. ################################################################################
  1390. # Generate strongSwan Monster Root CA
  1391. pki --gen --type rsa --size ${MONSTER_CA_RSA_SIZE} --outform pem > ${MONSTER_KEY}
  1392. pki --self --type rsa --in ${MONSTER_KEY} \
  1393. --not-before "01.05.09 15:00:00" --not-after "01.05.59 15:00:00" --ca \
  1394. --dn "C=CH, O=${PROJECT}, CN=strongSwan Monster CA" \
  1395. --outform pem > ${MONSTER_CERT}
  1396. # Put a copy in the ikev2/after-2038-certs scenario
  1397. TEST="${TEST_DIR}/ikev2/after-2038-certs"
  1398. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  1399. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/cacerts
  1400. cp ${MONSTER_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/cacerts
  1401. cp ${MONSTER_CERT} ${TEST}/hosts/carol/${IPSEC_DIR}/cacerts
  1402. # Generate a moon Monster certificate
  1403. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/moonKey.pem"
  1404. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/certs/moonCert.pem"
  1405. CN="moon.strongswan.org"
  1406. SERIAL="01"
  1407. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  1408. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  1409. pki --gen --type rsa --size ${MONSTER_EE_RSA_SIZE} --outform pem > ${TEST_KEY}
  1410. pki --issue --cakey ${MONSTER_KEY} --cacert ${MONSTER_CERT} --type rsa \
  1411. --in ${TEST_KEY} --san ${CN} \
  1412. --not-before "01.05.09 15:00:00" --not-after "01.05.39 15:00:00" - \
  1413. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Monster, CN=${CN}" \
  1414. --crl ${MONSTER_CDP} --outform pem > ${TEST_CERT}
  1415. cp ${TEST_CERT} ${MONSTER_DIR}/certs/${SERIAL}.pem
  1416. # Generate a carol Monster certificate
  1417. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey.pem"
  1418. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert.pem"
  1419. CN="carol@strongswan.org"
  1420. SERIAL="02"
  1421. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  1422. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  1423. pki --gen --type rsa --size ${MONSTER_EE_RSA_SIZE} --outform pem > ${TEST_KEY}
  1424. pki --issue --cakey ${MONSTER_KEY} --cacert ${MONSTER_CERT} --type rsa \
  1425. --in ${TEST_KEY} --san ${CN} \
  1426. --not-before "01.05.09 15:00:00" --not-after "01.05.39 15:00:00" - \
  1427. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=Monster, CN=${CN}" \
  1428. --crl ${MONSTER_CDP} --outform pem > ${TEST_CERT}
  1429. cp ${TEST_CERT} ${MONSTER_DIR}/certs/${SERIAL}.pem
  1430. ################################################################################
  1431. # Bliss CA #
  1432. ################################################################################
  1433. # Generate BLISS Root CA with 192 bit security strength
  1434. pki --gen --type bliss --size 4 > ${BLISS_KEY}
  1435. pki --self --type bliss --in ${BLISS_KEY} --digest sha3_512 \
  1436. --not-before "${START}" --not-after "${CA_END}" --ca \
  1437. --dn "C=CH, O=${PROJECT}, CN=strongSwan BLISS Root CA" > ${BLISS_CERT}
  1438. # Put a copy in the following scenarios
  1439. for t in rw-newhope-bliss rw-ntru-bliss
  1440. do
  1441. TEST="${TEST_DIR}/ikev2/${t}"
  1442. for h in moon carol dave
  1443. do
  1444. mkdir -p ${TEST}/hosts/${h}/${IPSEC_DIR}/cacerts
  1445. cp ${BLISS_CERT} ${TEST}/hosts/${h}/${IPSEC_DIR}/cacerts
  1446. done
  1447. TEST="${TEST_DIR}/swanctl/${t}"
  1448. for h in moon carol dave
  1449. do
  1450. mkdir -p ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  1451. cp ${BLISS_CERT} ${TEST}/hosts/${h}/${SWANCTL_DIR}/x509ca
  1452. done
  1453. done
  1454. # Generate a carol BLISS certificate with 128 bit security strength
  1455. TEST="${TEST_DIR}/ikev2/rw-newhope-bliss"
  1456. TEST_KEY="${TEST}/hosts/carol/${IPSEC_DIR}/private/carolKey.der"
  1457. TEST_CERT="${TEST}/hosts/carol/${IPSEC_DIR}/certs/carolCert.der"
  1458. CN="carol@strongswan.org"
  1459. SERIAL="01"
  1460. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  1461. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  1462. pki --gen --type bliss --size 1 > ${TEST_KEY}
  1463. pki --issue --cakey ${BLISS_KEY} --cacert ${BLISS_CERT} --type bliss \
  1464. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1465. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=BLISS I, CN=${CN}" \
  1466. --crl ${BLISS_CDP} --digest sha3_512 > ${TEST_CERT}
  1467. cp ${TEST_CERT} ${BLISS_DIR}/certs/${SERIAL}.der
  1468. # Put a copy in the ikev2/rw-ntru-bliss scenario
  1469. TEST="${TEST_DIR}/ikev2/rw-ntru-bliss"
  1470. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/private
  1471. mkdir -p ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  1472. cp ${TEST_KEY} ${TEST}/hosts/carol/${IPSEC_DIR}/private
  1473. cp ${TEST_CERT} ${TEST}/hosts/carol/${IPSEC_DIR}/certs
  1474. # Put a copy in the swanctl scenarios
  1475. for t in rw-newhope-bliss rw-ntru-bliss
  1476. do
  1477. TEST="${TEST_DIR}/swanctl/${t}"
  1478. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/bliss
  1479. mkdir -p ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1480. cp ${TEST_KEY} ${TEST}/hosts/carol/${SWANCTL_DIR}/bliss
  1481. cp ${TEST_CERT} ${TEST}/hosts/carol/${SWANCTL_DIR}/x509
  1482. done
  1483. # Generate a dave BLISS certificate with 160 bit security strength
  1484. TEST="${TEST_DIR}/ikev2/rw-newhope-bliss"
  1485. TEST_KEY="${TEST}/hosts/dave/${IPSEC_DIR}/private/daveKey.der"
  1486. TEST_CERT="${TEST}/hosts/dave/${IPSEC_DIR}/certs/daveCert.der"
  1487. CN="dave@strongswan.org"
  1488. SERIAL="02"
  1489. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  1490. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  1491. pki --gen --type bliss --size 3 > ${TEST_KEY}
  1492. pki --issue --cakey ${BLISS_KEY} --cacert ${BLISS_CERT} --type bliss \
  1493. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1494. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=BLISS III, CN=${CN}" \
  1495. --crl ${BLISS_CDP} --digest sha3_512 > ${TEST_CERT}
  1496. cp ${TEST_CERT} ${BLISS_DIR}/certs/${SERIAL}.der
  1497. # Put a copy in the ikev2/rw-ntru-bliss scenario
  1498. TEST="${TEST_DIR}/ikev2/rw-ntru-bliss"
  1499. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/private
  1500. mkdir -p ${TEST}/hosts/dave/${IPSEC_DIR}/certs
  1501. cp ${TEST_KEY} ${TEST}/hosts/dave/${IPSEC_DIR}/private/
  1502. cp ${TEST_CERT} ${TEST}/hosts/dave/${IPSEC_DIR}/certs/
  1503. # Put a copy in the swanctl scenarios
  1504. for t in rw-newhope-bliss rw-ntru-bliss
  1505. do
  1506. TEST="${TEST_DIR}/swanctl/${t}"
  1507. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/bliss
  1508. mkdir -p ${TEST}/hosts/dave/${SWANCTL_DIR}/x509
  1509. cp ${TEST_KEY} ${TEST}/hosts/dave/${SWANCTL_DIR}/bliss/
  1510. cp ${TEST_CERT} ${TEST}/hosts/dave/${SWANCTL_DIR}/x509/
  1511. done
  1512. # Generate a moon BLISS certificate with 192 bit security strength
  1513. TEST="${TEST_DIR}/ikev2/rw-newhope-bliss"
  1514. TEST_KEY="${TEST}/hosts/moon/${IPSEC_DIR}/private/moonKey.der"
  1515. TEST_CERT="${TEST}/hosts/moon/${IPSEC_DIR}/certs/moonCert.der"
  1516. CN="moon.strongswan.org"
  1517. SERIAL="03"
  1518. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  1519. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  1520. pki --gen --type bliss --size 4 > ${TEST_KEY}
  1521. pki --issue --cakey ${BLISS_KEY} --cacert ${BLISS_CERT} --type bliss \
  1522. --in ${TEST_KEY} --not-before "${START}" --not-after "${EE_END}" --san ${CN} \
  1523. --serial ${SERIAL} --dn "C=CH, O=${PROJECT}, OU=BLISS IV, CN=${CN}" \
  1524. --crl ${BLISS_CDP} --digest sha3_512 > ${TEST_CERT}
  1525. cp ${TEST_CERT} ${BLISS_DIR}/certs/${SERIAL}.der
  1526. # Put a copy in the ikev2/rw-ntru-bliss scenario
  1527. TEST="${TEST_DIR}/ikev2/rw-ntru-bliss"
  1528. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/private
  1529. mkdir -p ${TEST}/hosts/moon/${IPSEC_DIR}/certs
  1530. cp ${TEST_KEY} ${TEST}/hosts/moon/${IPSEC_DIR}/private/
  1531. cp ${TEST_CERT} ${TEST}/hosts/moon/${IPSEC_DIR}/certs/
  1532. # Put a copy in the swanctl scenarios
  1533. for t in rw-newhope-bliss rw-ntru-bliss
  1534. do
  1535. TEST="${TEST_DIR}/swanctl/${t}"
  1536. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/bliss
  1537. mkdir -p ${TEST}/hosts/moon/${SWANCTL_DIR}/x509
  1538. cp ${TEST_KEY} ${TEST}/hosts/moon/${SWANCTL_DIR}/bliss/
  1539. cp ${TEST_CERT} ${TEST}/hosts/moon/${SWANCTL_DIR}/x509/
  1540. done
  1541. ################################################################################
  1542. # SQL Data #
  1543. ################################################################################
  1544. CA_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${CA_KEY}`
  1545. CA_SPKI_HEX=`pki --keyid --type rsa --format hex --id spki --in ${CA_KEY}`
  1546. CA_CERT_HEX=`cat ${CA_CERT_DER} | hexdump -v -e '/1 "%02x"'`
  1547. CA_CERT_PEM_HEX=`cat ${CA_CERT} | hexdump -v -e '/1 "%02x"'`
  1548. #
  1549. MOON_CERT="${DIR}/hosts/moon/${SWANCTL_DIR}/x509/moonCert.pem"
  1550. MOON_KEY="${CA_DIR}/keys/moonKey.der"
  1551. MOON_KEY_PEM="${DIR}/hosts/moon/${SWANCTL_DIR}/rsa/moonKey.pem"
  1552. MOON_KEY_PEM_HEX=`cat ${MOON_KEY_PEM} | hexdump -v -e '/1 "%02x"'`
  1553. MOON_KEY_HEX=`cat ${MOON_KEY} | hexdump -v -e '/1 "%02x"'`
  1554. MOON_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${MOON_KEY}`
  1555. MOON_PUB_HEX=`pki --pub --type rsa --in ${MOON_KEY} | hexdump -v -e '/1 "%02x"'`
  1556. MOON_CERT_HEX=`openssl x509 -in ${MOON_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1557. MOON_CERT_PEM_HEX=`cat ${MOON_CERT} | hexdump -v -e '/1 "%02x"'`
  1558. #
  1559. SUN_CERT="${DIR}/hosts/sun/${SWANCTL_DIR}/x509/sunCert.pem"
  1560. SUN_KEY="${CA_DIR}/keys/sunKey.der"
  1561. SUN_KEY_PEM="${DIR}/hosts/sun/${SWANCTL_DIR}/rsa/sunKey.pem"
  1562. SUN_KEY_PEM_HEX=`cat ${SUN_KEY_PEM} | hexdump -v -e '/1 "%02x"'`
  1563. SUN_KEY_HEX=`cat ${SUN_KEY} | hexdump -v -e '/1 "%02x"'`
  1564. SUN_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${SUN_KEY}`
  1565. SUN_CERT_HEX=`openssl x509 -in ${SUN_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1566. SUN_CERT_PEM_HEX=`cat ${SUN_CERT} | hexdump -v -e '/1 "%02x"'`
  1567. #
  1568. CAROL_CERT="${DIR}/hosts/carol/${SWANCTL_DIR}/x509/carolCert.pem"
  1569. CAROL_KEY="${CA_DIR}/keys/carolKey.der"
  1570. CAROL_KEY_HEX=`cat ${CAROL_KEY} | hexdump -v -e '/1 "%02x"'`
  1571. CAROL_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${CAROL_KEY}`
  1572. CAROL_PUB_HEX=`pki --pub --type rsa --in ${CAROL_KEY} | hexdump -v -e '/1 "%02x"'`
  1573. CAROL_CERT_HEX=`openssl x509 -in ${CAROL_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1574. #
  1575. DAVE_CERT="${DIR}/hosts/dave/${SWANCTL_DIR}/x509/daveCert.pem"
  1576. DAVE_KEY="${CA_DIR}/keys/daveKey.der"
  1577. DAVE_KEY_HEX=`cat ${DAVE_KEY} | hexdump -v -e '/1 "%02x"'`
  1578. DAVE_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${DAVE_KEY}`
  1579. DAVE_PUB_HEX=`pki --pub --type rsa --in ${DAVE_KEY} | hexdump -v -e '/1 "%02x"'`
  1580. DAVE_CERT_HEX=`openssl x509 -in ${DAVE_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1581. #
  1582. ALICE_CERT="${DIR}/hosts/alice/${SWANCTL_DIR}/x509/aliceCert.pem"
  1583. ALICE_KEY="${CA_DIR}/keys/aliceKey.der"
  1584. ALICE_KEY_HEX=`cat ${ALICE_KEY} | hexdump -v -e '/1 "%02x"'`
  1585. ALICE_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${ALICE_KEY}`
  1586. ALICE_CERT_HEX=`openssl x509 -in ${ALICE_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1587. #
  1588. VENUS_CERT="${DIR}/hosts/venus/${SWANCTL_DIR}/x509/venusCert.pem"
  1589. VENUS_KEY="${CA_DIR}/keys/venusKey.der"
  1590. VENUS_KEY_HEX=`cat ${VENUS_KEY} | hexdump -v -e '/1 "%02x"'`
  1591. VENUS_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${VENUS_KEY}`
  1592. VENUS_CERT_HEX=`openssl x509 -in ${VENUS_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1593. #
  1594. RESEARCH_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${RESEARCH_KEY}`
  1595. RESEARCH_SPKI_HEX=`pki --keyid --type rsa --format hex --id spki --in ${RESEARCH_KEY}`
  1596. RESEARCH_CERT_HEX=`cat ${RESEARCH_CERT_DER} | hexdump -v -e '/1 "%02x"'`
  1597. #
  1598. CAROL_R_CERT="${RESEARCH_DIR}/certs/01.pem"
  1599. CAROL_R_KEY="${RESEARCH_DIR}/keys/01.der"
  1600. CAROL_R_KEY_HEX=`cat ${CAROL_R_KEY} | hexdump -v -e '/1 "%02x"'`
  1601. CAROL_R_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${CAROL_R_KEY}`
  1602. CAROL_R_CERT_HEX=`openssl x509 -in ${CAROL_R_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1603. #
  1604. SALES_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${SALES_KEY}`
  1605. SALES_SPKI_HEX=`pki --keyid --type rsa --format hex --id spki --in ${SALES_KEY}`
  1606. SALES_CERT_HEX=`cat ${SALES_CERT_DER} | hexdump -v -e '/1 "%02x"'`
  1607. #
  1608. DAVE_S_CERT="${SALES_DIR}/certs/01.pem"
  1609. DAVE_S_KEY="${SALES_DIR}/keys/01.der"
  1610. DAVE_S_KEY_HEX=`cat ${DAVE_S_KEY} | hexdump -v -e '/1 "%02x"'`
  1611. DAVE_S_SPK_HEX=`pki --keyid --type rsa --format hex --id spk --in ${DAVE_S_KEY}`
  1612. DAVE_S_CERT_HEX=`openssl x509 -in ${DAVE_S_CERT} -outform der | hexdump -v -e '/1 "%02x"'`
  1613. #
  1614. for t in ip-pool-db ip-pool-db-expired ip-pool-db-restart ip-split-pools-db \
  1615. ip-split-pools-db-restart multi-level-ca rw-cert rw-psk-rsa-split \
  1616. rw-psk-ipv4 rw-psk-ipv6 rw-rsa rw-rsa-keyid
  1617. do
  1618. for h in carol dave moon
  1619. do
  1620. TEST_DATA="${TEST_DIR}/sql/${t}/hosts/${h}/${IPSEC_DIR}/data.sql"
  1621. sed -e "s/CA_SPK_HEX/${CA_SPK_HEX}/g" \
  1622. -e "s/CA_SPKI_HEX/${CA_SPKI_HEX}/g" \
  1623. -e "s/CA_CERT_HEX/${CA_CERT_HEX}/g" \
  1624. -e "s/MOON_KEY_HEX/${MOON_KEY_HEX}/g" \
  1625. -e "s/MOON_SPK_HEX/${MOON_SPK_HEX}/g" \
  1626. -e "s/MOON_PUB_HEX/${MOON_PUB_HEX}/g" \
  1627. -e "s/MOON_CERT_HEX/${MOON_CERT_HEX}/g" \
  1628. -e "s/CAROL_KEY_HEX/${CAROL_KEY_HEX}/g" \
  1629. -e "s/CAROL_SPK_HEX/${CAROL_SPK_HEX}/g" \
  1630. -e "s/CAROL_PUB_HEX/${CAROL_PUB_HEX}/g" \
  1631. -e "s/CAROL_CERT_HEX/${CAROL_CERT_HEX}/g" \
  1632. -e "s/DAVE_KEY_HEX/${DAVE_KEY_HEX}/g" \
  1633. -e "s/DAVE_SPK_HEX/${DAVE_SPK_HEX}/g" \
  1634. -e "s/DAVE_PUB_HEX/${DAVE_PUB_HEX}/g" \
  1635. -e "s/DAVE_CERT_HEX/${DAVE_CERT_HEX}/g" \
  1636. -e "s/RESEARCH_SPK_HEX/${RESEARCH_SPK_HEX}/g" \
  1637. -e "s/RESEARCH_SPKI_HEX/${RESEARCH_SPKI_HEX}/g" \
  1638. -e "s/RESEARCH_CERT_HEX/${RESEARCH_CERT_HEX}/g" \
  1639. -e "s/CAROL_R_KEY_HEX/${CAROL_R_KEY_HEX}/g" \
  1640. -e "s/CAROL_R_SPK_HEX/${CAROL_R_SPK_HEX}/g" \
  1641. -e "s/CAROL_R_CERT_HEX/${CAROL_R_CERT_HEX}/g" \
  1642. -e "s/SALES_SPK_HEX/${SALES_SPK_HEX}/g" \
  1643. -e "s/SALES_SPKI_HEX/${SALES_SPKI_HEX}/g" \
  1644. -e "s/SALES_CERT_HEX/${SALES_CERT_HEX}/g" \
  1645. -e "s/DAVE_S_KEY_HEX/${DAVE_S_KEY_HEX}/g" \
  1646. -e "s/DAVE_S_SPK_HEX/${DAVE_S_SPK_HEX}/g" \
  1647. -e "s/DAVE_S_CERT_HEX/${DAVE_S_CERT_HEX}/g" \
  1648. ${TEST_DATA}.in > ${TEST_DATA}
  1649. done
  1650. done
  1651. #
  1652. for t in rw-eap-aka-rsa
  1653. do
  1654. for h in carol moon
  1655. do
  1656. TEST_DATA="${TEST_DIR}/sql/${t}/hosts/${h}/${IPSEC_DIR}/data.sql"
  1657. sed -e "s/CA_SPK_HEX/${CA_SPK_HEX}/g" \
  1658. -e "s/CA_SPKI_HEX/${CA_SPKI_HEX}/g" \
  1659. -e "s/CA_CERT_HEX/${CA_CERT_HEX}/g" \
  1660. -e "s/MOON_KEY_HEX/${MOON_KEY_HEX}/g" \
  1661. -e "s/MOON_SPK_HEX/${MOON_SPK_HEX}/g" \
  1662. -e "s/MOON_CERT_HEX/${MOON_CERT_HEX}/g" \
  1663. ${TEST_DATA}.in > ${TEST_DATA}
  1664. done
  1665. done
  1666. #
  1667. for t in net2net-cert net2net-psk net2net-route-pem net2net-start-pem
  1668. do
  1669. for h in moon sun
  1670. do
  1671. TEST_DATA="${TEST_DIR}/sql/${t}/hosts/${h}/${IPSEC_DIR}/data.sql"
  1672. sed -e "s/CA_SPK_HEX/${CA_SPK_HEX}/g" \
  1673. -e "s/CA_SPKI_HEX/${CA_SPKI_HEX}/g" \
  1674. -e "s/CA_CERT_HEX/${CA_CERT_HEX}/g" \
  1675. -e "s/CA_CERT_PEM_HEX/${CA_CERT_PEM_HEX}/g" \
  1676. -e "s/MOON_KEY_PEM_HEX/${MOON_KEY_PEM_HEX}/g" \
  1677. -e "s/MOON_KEY_HEX/${MOON_KEY_HEX}/g" \
  1678. -e "s/MOON_SPK_HEX/${MOON_SPK_HEX}/g" \
  1679. -e "s/MOON_CERT_HEX/${MOON_CERT_HEX}/g" \
  1680. -e "s/MOON_CERT_PEM_HEX/${MOON_CERT_PEM_HEX}/g" \
  1681. -e "s/SUN_KEY_PEM_HEX/${SUN_KEY_PEM_HEX}/g" \
  1682. -e "s/SUN_KEY_HEX/${SUN_KEY_HEX}/g" \
  1683. -e "s/SUN_SPK_HEX/${SUN_SPK_HEX}/g" \
  1684. -e "s/SUN_CERT_HEX/${SUN_CERT_HEX}/g" \
  1685. -e "s/SUN_CERT_PEM_HEX/${SUN_CERT_PEM_HEX}/g" \
  1686. ${TEST_DATA}.in > ${TEST_DATA}
  1687. done
  1688. done
  1689. #
  1690. for t in shunt-policies-nat-rw
  1691. do
  1692. for h in alice venus sun
  1693. do
  1694. TEST_DATA="${TEST_DIR}/sql/${t}/hosts/${h}/${IPSEC_DIR}/data.sql"
  1695. sed -e "s/CA_SPK_HEX/${CA_SPK_HEX}/g" \
  1696. -e "s/CA_SPKI_HEX/${CA_SPKI_HEX}/g" \
  1697. -e "s/CA_CERT_HEX/${CA_CERT_HEX}/g" \
  1698. -e "s/ALICE_KEY_HEX/${ALICE_KEY_HEX}/g" \
  1699. -e "s/ALICE_SPK_HEX/${ALICE_SPK_HEX}/g" \
  1700. -e "s/ALICE_CERT_HEX/${ALICE_CERT_HEX}/g" \
  1701. -e "s/VENUS_KEY_HEX/${VENUS_KEY_HEX}/g" \
  1702. -e "s/VENUS_SPK_HEX/${VENUS_SPK_HEX}/g" \
  1703. -e "s/VENUS_CERT_HEX/${VENUS_CERT_HEX}/g" \
  1704. -e "s/SUN_KEY_HEX/${SUN_KEY_HEX}/g" \
  1705. -e "s/SUN_SPK_HEX/${SUN_SPK_HEX}/g" \
  1706. -e "s/SUN_CERT_HEX/${SUN_CERT_HEX}/g" \
  1707. ${TEST_DATA}.in > ${TEST_DATA}
  1708. done
  1709. done
  1710. ################################################################################
  1711. # Raw RSA keys #
  1712. ################################################################################
  1713. MOON_PUB_DNS=`pki --pub --type rsa --outform dnskey --in ${MOON_KEY}`
  1714. #
  1715. SUN_PUB_DNS=`pki --pub --type rsa --outform dnskey --in ${SUN_KEY}`
  1716. #
  1717. for h in moon sun
  1718. do
  1719. TEST_DATA="${TEST_DIR}/ikev2/net2net-rsa/hosts/${h}/etc/ipsec.conf"
  1720. sed -e "s|MOON_PUB_DNS|${MOON_PUB_DNS}|g" \
  1721. -e "s|SUN_PUB_DNS|${SUN_PUB_DNS}|g" \
  1722. ${TEST_DATA}.in > ${TEST_DATA}
  1723. done