2
0

setup.sh 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. #! /bin/bash
  2. # Primary root: root-cert
  3. ./mkcert.sh genroot "Root CA" root-key root-cert
  4. # root cert variants: CA:false, key2, DN2, expired
  5. ./mkcert.sh genss "Root CA" root-key root-nonca
  6. ./mkcert.sh genroot "Root CA" root-key2 root-cert2
  7. ./mkcert.sh genroot "Root Cert 2" root-key root-name2
  8. DAYS=-1 ./mkcert.sh genroot "Root CA" root-key root-expired
  9. # cross root and root cross cert
  10. ./mkcert.sh genroot "Cross Root" cross-key cross-root
  11. ./mkcert.sh genca "Root CA" root-key root-cross-cert cross-key cross-root
  12. # trust variants: +serverAuth -serverAuth +clientAuth -clientAuth
  13. openssl x509 -in root-cert.pem -trustout \
  14. -addtrust serverAuth -out root+serverAuth.pem
  15. openssl x509 -in root-cert.pem -trustout \
  16. -addreject serverAuth -out root-serverAuth.pem
  17. openssl x509 -in root-cert.pem -trustout \
  18. -addtrust clientAuth -out root+clientAuth.pem
  19. openssl x509 -in root-cert.pem -trustout \
  20. -addreject clientAuth -out root-clientAuth.pem
  21. # trust variants: +anyEKU -anyEKU
  22. openssl x509 -in root-cert.pem -trustout \
  23. -addtrust anyExtendedKeyUsage -out root+anyEKU.pem
  24. openssl x509 -in root-cert.pem -trustout \
  25. -addreject anyExtendedKeyUsage -out root-anyEKU.pem
  26. # root-cert2 trust variants: +serverAuth -serverAuth +clientAuth
  27. openssl x509 -in root-cert2.pem -trustout \
  28. -addtrust serverAuth -out root2+serverAuth.pem
  29. openssl x509 -in root-cert2.pem -trustout \
  30. -addreject serverAuth -out root2-serverAuth.pem
  31. openssl x509 -in root-cert2.pem -trustout \
  32. -addtrust clientAuth -out root2+clientAuth.pem
  33. # root-nonca trust variants: +serverAuth +anyEKU
  34. openssl x509 -in root-nonca.pem -trustout \
  35. -addtrust serverAuth -out nroot+serverAuth.pem
  36. openssl x509 -in root-nonca.pem -trustout \
  37. -addtrust anyExtendedKeyUsage -out nroot+anyEKU.pem
  38. # Root CA security level variants:
  39. # MD5 self-signature
  40. OPENSSL_SIGALG=md5 \
  41. ./mkcert.sh genroot "Root CA" root-key root-cert-md5
  42. # 768-bit key
  43. OPENSSL_KEYBITS=768 \
  44. ./mkcert.sh genroot "Root CA" root-key-768 root-cert-768
  45. # primary client-EKU root: croot-cert
  46. ./mkcert.sh genroot "Root CA" root-key croot-cert clientAuth
  47. # trust variants: +serverAuth -serverAuth +clientAuth -clientAuth +anyEKU -anyEKU
  48. openssl x509 -in croot-cert.pem -trustout \
  49. -addtrust serverAuth -out croot+serverAuth.pem
  50. openssl x509 -in croot-cert.pem -trustout \
  51. -addreject serverAuth -out croot-serverAuth.pem
  52. openssl x509 -in croot-cert.pem -trustout \
  53. -addtrust clientAuth -out croot+clientAuth.pem
  54. openssl x509 -in croot-cert.pem -trustout \
  55. -addreject clientAuth -out croot-clientAuth.pem
  56. openssl x509 -in croot-cert.pem -trustout \
  57. -addtrust anyExtendedKeyUsage -out croot+anyEKU.pem
  58. openssl x509 -in croot-cert.pem -trustout \
  59. -addreject anyExtendedKeyUsage -out croot-anyEKU.pem
  60. # primary server-EKU root: sroot-cert
  61. ./mkcert.sh genroot "Root CA" root-key sroot-cert serverAuth
  62. # trust variants: +serverAuth -serverAuth +clientAuth -clientAuth +anyEKU -anyEKU
  63. openssl x509 -in sroot-cert.pem -trustout \
  64. -addtrust serverAuth -out sroot+serverAuth.pem
  65. openssl x509 -in sroot-cert.pem -trustout \
  66. -addreject serverAuth -out sroot-serverAuth.pem
  67. openssl x509 -in sroot-cert.pem -trustout \
  68. -addtrust clientAuth -out sroot+clientAuth.pem
  69. openssl x509 -in sroot-cert.pem -trustout \
  70. -addreject clientAuth -out sroot-clientAuth.pem
  71. openssl x509 -in sroot-cert.pem -trustout \
  72. -addtrust anyExtendedKeyUsage -out sroot+anyEKU.pem
  73. openssl x509 -in sroot-cert.pem -trustout \
  74. -addreject anyExtendedKeyUsage -out sroot-anyEKU.pem
  75. # Primary intermediate ca: ca-cert
  76. ./mkcert.sh genca "CA" ca-key ca-cert root-key root-cert
  77. # ca variants: CA:false, no bc, key2, DN2, issuer2, expired
  78. ./mkcert.sh genee "CA" ca-key ca-nonca root-key root-cert
  79. ./mkcert.sh gen_nonbc_ca "CA" ca-key ca-nonbc root-key root-cert
  80. ./mkcert.sh genca "CA" ca-key2 ca-cert2 root-key root-cert
  81. ./mkcert.sh genca "CA2" ca-key ca-name2 root-key root-cert
  82. ./mkcert.sh genca "CA" ca-key ca-root2 root-key2 root-cert2
  83. DAYS=-1 ./mkcert.sh genca "CA" ca-key ca-expired root-key root-cert
  84. # trust variants: +serverAuth, -serverAuth, +clientAuth, -clientAuth
  85. openssl x509 -in ca-cert.pem -trustout \
  86. -addtrust serverAuth -out ca+serverAuth.pem
  87. openssl x509 -in ca-cert.pem -trustout \
  88. -addreject serverAuth -out ca-serverAuth.pem
  89. openssl x509 -in ca-cert.pem -trustout \
  90. -addtrust clientAuth -out ca+clientAuth.pem
  91. openssl x509 -in ca-cert.pem -trustout \
  92. -addreject clientAuth -out ca-clientAuth.pem
  93. # trust variants: +anyEKU, -anyEKU
  94. openssl x509 -in ca-cert.pem -trustout \
  95. -addtrust anyExtendedKeyUsage -out ca+anyEKU.pem
  96. openssl x509 -in ca-cert.pem -trustout \
  97. -addreject anyExtendedKeyUsage -out ca-anyEKU.pem
  98. # ca-nonca trust variants: +serverAuth, +anyEKU
  99. openssl x509 -in ca-nonca.pem -trustout \
  100. -addtrust serverAuth -out nca+serverAuth.pem
  101. openssl x509 -in ca-nonca.pem -trustout \
  102. -addtrust anyExtendedKeyUsage -out nca+anyEKU.pem
  103. # Intermediate CA security variants:
  104. # MD5 issuer signature,
  105. OPENSSL_SIGALG=md5 \
  106. ./mkcert.sh genca "CA" ca-key ca-cert-md5 root-key root-cert
  107. openssl x509 -in ca-cert-md5.pem -trustout \
  108. -addtrust anyExtendedKeyUsage -out ca-cert-md5-any.pem
  109. # Issuer has 768-bit key
  110. ./mkcert.sh genca "CA" ca-key ca-cert-768i root-key-768 root-cert-768
  111. # CA has 768-bit key
  112. OPENSSL_KEYBITS=768 \
  113. ./mkcert.sh genca "CA" ca-key-768 ca-cert-768 root-key root-cert
  114. # EC cert with explicit curve
  115. ./mkcert.sh genca "CA" ca-key-ec-explicit ca-cert-ec-explicit root-key root-cert
  116. # EC cert with named curve
  117. ./mkcert.sh genca "CA" ca-key-ec-named ca-cert-ec-named root-key root-cert
  118. # client intermediate ca: cca-cert
  119. ./mkcert.sh genca -p clientAuth "CA" ca-key cca-cert root-key root-cert
  120. # trust variants: +serverAuth, -serverAuth, +clientAuth, -clientAuth, +anyEKU, -anyEKU
  121. openssl x509 -in cca-cert.pem -trustout \
  122. -addtrust serverAuth -out cca+serverAuth.pem
  123. openssl x509 -in cca-cert.pem -trustout \
  124. -addreject serverAuth -out cca-serverAuth.pem
  125. openssl x509 -in cca-cert.pem -trustout \
  126. -addtrust clientAuth -out cca+clientAuth.pem
  127. openssl x509 -in cca-cert.pem -trustout \
  128. -addreject clientAuth -out cca-clientAuth.pem
  129. openssl x509 -in cca-cert.pem -trustout \
  130. -addtrust anyExtendedKeyUsage -out cca+anyEKU.pem
  131. openssl x509 -in cca-cert.pem -trustout \
  132. -addreject anyExtendedKeyUsage -out cca-anyEKU.pem
  133. # server intermediate ca: sca-cert
  134. ./mkcert.sh genca -p serverAuth "CA" ca-key sca-cert root-key root-cert
  135. # trust variants: +serverAuth, -serverAuth, +clientAuth, -clientAuth, +anyEKU, -anyEKU
  136. openssl x509 -in sca-cert.pem -trustout \
  137. -addtrust serverAuth -out sca+serverAuth.pem
  138. openssl x509 -in sca-cert.pem -trustout \
  139. -addreject serverAuth -out sca-serverAuth.pem
  140. openssl x509 -in sca-cert.pem -trustout \
  141. -addtrust clientAuth -out sca+clientAuth.pem
  142. openssl x509 -in sca-cert.pem -trustout \
  143. -addreject clientAuth -out sca-clientAuth.pem
  144. openssl x509 -in sca-cert.pem -trustout \
  145. -addtrust anyExtendedKeyUsage -out sca+anyEKU.pem
  146. openssl x509 -in sca-cert.pem -trustout \
  147. -addreject anyExtendedKeyUsage -out sca-anyEKU.pem
  148. # Primary leaf cert: ee-cert with default purpose: serverAuth
  149. ./mkcert.sh genee server.example ee-key ee-cert ca-key ca-cert
  150. # ee variants: expired, issuer-key2, issuer-name2, bad-pathlen
  151. ./mkcert.sh genee server.example ee-key ee-expired ca-key ca-cert -days -1
  152. ./mkcert.sh genee server.example ee-key ee-cert2 ca-key2 ca-cert2
  153. ./mkcert.sh genee server.example ee-key ee-name2 ca-key ca-name2
  154. ./mkcert.sh genee server.example ee-key ee-pathlen ca-key ca-cert \
  155. -extfile <(echo "basicConstraints=CA:false,pathlen:0") # bash needed here
  156. # purpose variants: clientAuth
  157. ./mkcert.sh genee -p clientAuth server.example ee-key ee-client ca-key ca-cert
  158. # trust variants: +serverAuth, -serverAuth, +clientAuth, -clientAuth
  159. openssl x509 -in ee-cert.pem -trustout \
  160. -addtrust serverAuth -out ee+serverAuth.pem
  161. openssl x509 -in ee-cert.pem -trustout \
  162. -addreject serverAuth -out ee-serverAuth.pem
  163. openssl x509 -in ee-client.pem -trustout \
  164. -addtrust clientAuth -out ee+clientAuth.pem
  165. openssl x509 -in ee-client.pem -trustout \
  166. -addreject clientAuth -out ee-clientAuth.pem
  167. # time stamping certificates
  168. ./mkcert.sh genee -p critical,timeStamping -k critical,digitalSignature server.example ee-key ee-timestampsign-CABforum ca-key ca-cert
  169. ./mkcert.sh genee -p timeStamping -k critical,digitalSignature server.example ee-key ee-timestampsign-CABforum-noncritxku ca-key ca-cert
  170. ./mkcert.sh genee -p critical,timeStamping,serverAuth -k critical,digitalSignature server.example ee-key ee-timestampsign-CABforum-serverauth ca-key ca-cert
  171. ./mkcert.sh genee -p critical,timeStamping,2.5.29.37.0 -k critical,digitalSignature server.example ee-key ee-timestampsign-CABforum-anyextkeyusage ca-key ca-cert
  172. ./mkcert.sh genee -p critical,timeStamping -k critical,digitalSignature,cRLSign server.example ee-key ee-timestampsign-CABforum-crlsign ca-key ca-cert
  173. ./mkcert.sh genee -p critical,timeStamping -k critical,digitalSignature,keyCertSign server.example ee-key ee-timestampsign-CABforum-keycertsign ca-key ca-cert
  174. ./mkcert.sh genee -p critical,timeStamping server.example ee-key ee-timestampsign-rfc3161 ca-key ca-cert
  175. ./mkcert.sh genee -p timeStamping server.example ee-key ee-timestampsign-rfc3161-noncritxku ca-key ca-cert
  176. ./mkcert.sh genee -p critical,timeStamping -k digitalSignature server.example ee-key ee-timestampsign-rfc3161-digsig ca-key ca-cert
  177. # code signing certificate
  178. ./mkcert.sh genee -p codeSigning -k critical,digitalSignature server.example ee-key ee-codesign ca-key ca-cert
  179. ./mkcert.sh genee -p codeSigning,serverAuth -k critical,digitalSignature server.example ee-key ee-codesign-serverauth ca-key ca-cert
  180. ./mkcert.sh genee -p codeSigning,2.5.29.37.0 -k critical,digitalSignature server.example ee-key ee-codesign-anyextkeyusage ca-key ca-cert
  181. ./mkcert.sh genee -p codeSigning -k critical,digitalSignature,cRLSign server.example ee-key ee-codesign-crlsign ca-key ca-cert
  182. ./mkcert.sh genee -p codeSigning -k critical,digitalSignature,keyCertSign server.example ee-key ee-codesign-keycertsign ca-key ca-cert
  183. ./mkcert.sh genee -p codeSigning -k digitalSignature server.example ee-key ee-codesign-noncritical ca-key ca-cert
  184. # Leaf cert security level variants
  185. # MD5 issuer signature
  186. OPENSSL_SIGALG=md5 \
  187. ./mkcert.sh genee server.example ee-key ee-cert-md5 ca-key ca-cert
  188. # 768-bit issuer key
  189. ./mkcert.sh genee server.example ee-key ee-cert-768i ca-key-768 ca-cert-768
  190. # 768-bit leaf key
  191. OPENSSL_KEYBITS=768 \
  192. ./mkcert.sh genee server.example ee-key-768 ee-cert-768 ca-key ca-cert
  193. # EC cert with explicit curve signed by named curve ca
  194. ./mkcert.sh genee server.example ee-key-ec-explicit ee-cert-ec-explicit ca-key-ec-named ca-cert-ec-named
  195. # EC cert with named curve signed by explicit curve ca
  196. ./mkcert.sh genee server.example ee-key-ec-named-explicit \
  197. ee-cert-ec-named-explicit ca-key-ec-explicit ca-cert-ec-explicit
  198. # EC cert with named curve signed by named curve ca
  199. ./mkcert.sh genee server.example ee-key-ec-named-named \
  200. ee-cert-ec-named-named ca-key-ec-named ca-cert-ec-named
  201. # 1024-bit leaf key
  202. OPENSSL_KEYBITS=1024 \
  203. ./mkcert.sh genee server.example ee-key-1024 ee-cert-1024 ca-key ca-cert
  204. # 3072-bit leaf key
  205. OPENSSL_KEYBITS=3072 \
  206. ./mkcert.sh genee server.example ee-key-3072 ee-cert-3072 ca-key ca-cert
  207. # 4096-bit leaf key
  208. OPENSSL_KEYBITS=4096 \
  209. ./mkcert.sh genee server.example ee-key-4096 ee-cert-4096 ca-key ca-cert
  210. # 8192-bit leaf key
  211. OPENSSL_KEYBITS=8192 \
  212. ./mkcert.sh genee server.example ee-key-8192 ee-cert-8192 ca-key ca-cert
  213. # self-signed end-entity cert with explicit keyUsage not including KeyCertSign
  214. openssl req -new -x509 -key ee-key.pem -subj /CN=ee-self-signed -out ee-self-signed.pem -addext keyUsage=digitalSignature -days 36525
  215. # Proxy certificates, off of ee-client
  216. # Start with some good ones
  217. ./mkcert.sh req pc1-key "0.CN = server.example" "1.CN = proxy 1" | \
  218. ./mkcert.sh genpc pc1-key pc1-cert ee-key ee-client \
  219. "language = id-ppl-anyLanguage" "pathlen = 1" "policy = text:AB"
  220. ./mkcert.sh req pc2-key "0.CN = server.example" "1.CN = proxy 1" "2.CN = proxy 2" | \
  221. ./mkcert.sh genpc pc2-key pc2-cert pc1-key pc1-cert \
  222. "language = id-ppl-anyLanguage" "pathlen = 0" "policy = text:AB"
  223. # And now a couple of bad ones
  224. # pc3: incorrect CN
  225. ./mkcert.sh req bad-pc3-key "0.CN = server.example" "1.CN = proxy 3" | \
  226. ./mkcert.sh genpc bad-pc3-key bad-pc3-cert pc1-key pc1-cert \
  227. "language = id-ppl-anyLanguage" "pathlen = 0" "policy = text:AB"
  228. # pc4: incorrect pathlen
  229. ./mkcert.sh req bad-pc4-key "0.CN = server.example" "1.CN = proxy 1" "2.CN = proxy 4" | \
  230. ./mkcert.sh genpc bad-pc4-key bad-pc4-cert pc1-key pc1-cert \
  231. "language = id-ppl-anyLanguage" "pathlen = 1" "policy = text:AB"
  232. # pc5: no policy
  233. ./mkcert.sh req pc5-key "0.CN = server.example" "1.CN = proxy 1" "2.CN = proxy 5" | \
  234. ./mkcert.sh genpc pc5-key pc5-cert pc1-key pc1-cert \
  235. "language = id-ppl-anyLanguage" "pathlen = 0"
  236. # pc6: incorrect CN (made into a component of a multivalue RDN)
  237. ./mkcert.sh req bad-pc6-key "0.CN = server.example" "1.CN = proxy 1" "2.+CN = proxy 6" | \
  238. ./mkcert.sh genpc bad-pc6-key bad-pc6-cert pc1-key pc1-cert \
  239. "language = id-ppl-anyLanguage" "pathlen = 0" "policy = text:AB"
  240. # Name constraints test certificates.
  241. # NC CA1 only permits the host www.good.org and *.good.com email address
  242. # good@good.org and *@good.com and IP addresses 127.0.0.1 and
  243. # 192.168.0.0/16
  244. NC="permitted;DNS:www.good.org, permitted;DNS:good.com,"
  245. NC="$NC permitted;email:good@good.org, permitted;email:good.com,"
  246. NC="$NC permitted;IP:127.0.0.1/255.255.255.255, permitted;IP:192.168.0.0/255.255.0.0"
  247. NC=$NC ./mkcert.sh genca "Test NC CA 1" ncca1-key ncca1-cert root-key root-cert
  248. # NC CA2 allows anything apart from hosts www.bad.org and *.bad.com
  249. # and email addresses bad@bad.org and *@bad.com
  250. NC="excluded;DNS:www.bad.org, excluded;DNS:bad.com,"
  251. NC="$NC excluded;email:bad@bad.org, excluded;email:bad.com, "
  252. NC="$NC excluded;IP:10.0.0.0/255.0.0.0"
  253. NC=$NC ./mkcert.sh genca "Test NC CA 2" ncca2-key ncca2-cert root-key root-cert
  254. # Name constraints subordinate CA. Adds www.good.net (which should be
  255. # disallowed because parent CA doesn't permit it) adds ok.good.com
  256. # (which should be allowed because parent allows *.good.com
  257. # and now excludes bad.ok.good.com (allowed in permitted subtrees
  258. # but explicitly excluded).
  259. NC="permitted;DNS:www.good.net, permitted;DNS:ok.good.com, "
  260. NC="$NC excluded;DNS:bad.ok.good.com"
  261. NC=$NC ./mkcert.sh genca "Test NC sub CA" ncca3-key ncca3-cert \
  262. ncca1-key ncca1-cert
  263. # all subjectAltNames allowed by CA1. Some CNs are not!
  264. ./mkcert.sh req alt1-key "O = Good NC Test Certificate 1" \
  265. "1.CN=www.example.net" "2.CN=Joe Bloggs" | \
  266. ./mkcert.sh geneealt alt1-key alt1-cert ncca1-key ncca1-cert \
  267. "DNS.1 = www.good.org" "DNS.2 = any.good.com" \
  268. "email.1 = good@good.org" "email.2 = any@good.com" \
  269. "IP = 127.0.0.1" "IP = 192.168.0.1"
  270. # all DNS-like CNs allowed by CA1, no DNS SANs.
  271. ./mkcert.sh req goodcn1-key "O = Good NC Test Certificate 1" \
  272. "1.CN=www.good.org" "2.CN=any.good.com" \
  273. "3.CN=not..dns" "4.CN=not@dns" "5.CN=not-.dns" "6.CN=not.dns." | \
  274. ./mkcert.sh geneealt goodcn1-key goodcn1-cert ncca1-key ncca1-cert \
  275. "IP = 127.0.0.1" "IP = 192.168.0.1"
  276. # all DNS-like CNs allowed by CA1, no SANs
  277. ./mkcert.sh req goodcn2-key "O = Good NC Test Certificate 1" \
  278. "CN=www.good.org" | \
  279. ./mkcert.sh geneeconfig goodcn2-key goodcn2-cert ncca1-key ncca1-cert
  280. # Some DNS-like CNs not permitted by CA1, no DNS SANs.
  281. ./mkcert.sh req badcn1-key "O = Good NC Test Certificate 1" \
  282. "1.CN=www.good.org" "3.CN=bad.net" | \
  283. ./mkcert.sh geneealt badcn1-key badcn1-cert ncca1-key ncca1-cert \
  284. "IP = 127.0.0.1" "IP = 192.168.0.1"
  285. # no subjectAltNames excluded by CA2.
  286. ./mkcert.sh req alt2-key "O = Good NC Test Certificate 2" | \
  287. ./mkcert.sh geneealt alt2-key alt2-cert ncca2-key ncca2-cert \
  288. "DNS.1 = www.anything.org" "DNS.2 = any.other.com" \
  289. "email.1 = other@bad.org" "email.2 = any@something.com"
  290. # hostname other.good.org which is not allowed by CA1.
  291. ./mkcert.sh req badalt1-key "O = Bad NC Test Certificate 1" | \
  292. ./mkcert.sh geneealt badalt1-key badalt1-cert ncca1-key ncca1-cert \
  293. "DNS.1 = other.good.org" "DNS.2 = any.good.com" \
  294. "email.1 = good@good.org" "email.2 = any@good.com"
  295. # any.bad.com is excluded by CA2.
  296. ./mkcert.sh req badalt2-key 'O = Bad NC Test Certificate 2' | \
  297. ./mkcert.sh geneealt badalt2-key badalt2-cert ncca2-key ncca2-cert \
  298. "DNS.1 = www.good.org" "DNS.2 = any.bad.com" \
  299. "email.1 = good@good.org" "email.2 = any@good.com"
  300. # other@good.org not permitted by CA1
  301. ./mkcert.sh req badalt3-key "O = Bad NC Test Certificate 3" | \
  302. ./mkcert.sh geneealt badalt3-key badalt1-cert ncca1-key ncca1-cert \
  303. "DNS.1 = www.good.org" "DNS.2 = any.good.com" \
  304. "email.1 = other@good.org" "email.2 = any@good.com"
  305. # all subject alt names OK but subject email address not allowed by CA1.
  306. ./mkcert.sh req badalt4-key 'O = Bad NC Test Certificate 4' \
  307. "emailAddress = any@other.com" | \
  308. ./mkcert.sh geneealt badalt4-key badalt4-cert ncca1-key ncca1-cert \
  309. "DNS.1 = www.good.org" "DNS.2 = any.good.com" \
  310. "email.1 = good@good.org" "email.2 = any@good.com"
  311. # IP address not allowed by CA1
  312. ./mkcert.sh req badalt5-key "O = Bad NC Test Certificate 5" | \
  313. ./mkcert.sh geneealt badalt5-key badalt5-cert ncca1-key ncca1-cert \
  314. "DNS.1 = www.good.org" "DNS.2 = any.good.com" \
  315. "email.1 = good@good.org" "email.2 = any@good.com" \
  316. "IP = 127.0.0.2"
  317. # No DNS-ID SANs and subject CN not allowed by CA1.
  318. ./mkcert.sh req badalt6-key "O = Bad NC Test Certificate 6" \
  319. "1.CN=other.good.org" "2.CN=Joe Bloggs" "3.CN=any.good.com" | \
  320. ./mkcert.sh geneealt badalt6-key badalt6-cert ncca1-key ncca1-cert \
  321. "email.1 = good@good.org" "email.2 = any@good.com" \
  322. "IP = 127.0.0.1" "IP = 192.168.0.1"
  323. # No DNS-ID SANS and subject CN not allowed by CA1, BMPSTRING
  324. REQMASK=MASK:0x800 ./mkcert.sh req badalt7-key "O = Bad NC Test Certificate 7" \
  325. "1.CN=other.good.org" "2.CN=Joe Bloggs" "3.CN=any.good.com" | \
  326. ./mkcert.sh geneealt badalt7-key badalt7-cert ncca1-key ncca1-cert \
  327. "email.1 = good@good.org" "email.2 = any@good.com" \
  328. "IP = 127.0.0.1" "IP = 192.168.0.1"
  329. # all subjectAltNames allowed by chain
  330. ./mkcert.sh req alt3-key "O = Good NC Test Certificate 3" \
  331. "1.CN=www.ok.good.com" "2.CN=Joe Bloggs" | \
  332. ./mkcert.sh geneealt alt3-key alt3-cert ncca3-key ncca3-cert \
  333. "DNS.1 = www.ok.good.com" \
  334. "email.1 = good@good.org" "email.2 = any@good.com" \
  335. "IP = 127.0.0.1" "IP = 192.168.0.1"
  336. # www.good.net allowed by parent CA but not parent of parent
  337. ./mkcert.sh req badalt8-key "O = Bad NC Test Certificate 8" \
  338. "1.CN=www.good.com" "2.CN=Joe Bloggs" | \
  339. ./mkcert.sh geneealt badalt8-key badalt8-cert ncca3-key ncca3-cert \
  340. "DNS.1 = www.ok.good.com" "DNS.2 = www.good.net" \
  341. "email.1 = good@good.org" "email.2 = any@good.com" \
  342. "IP = 127.0.0.1" "IP = 192.168.0.1"
  343. # other.good.com not allowed by parent CA but allowed by parent of parent
  344. ./mkcert.sh req badalt9-key "O = Bad NC Test Certificate 9" \
  345. "1.CN=www.good.com" "2.CN=Joe Bloggs" | \
  346. ./mkcert.sh geneealt badalt9-key badalt9-cert ncca3-key ncca3-cert \
  347. "DNS.1 = www.good.com" "DNS.2 = other.good.com" \
  348. "email.1 = good@good.org" "email.2 = any@good.com" \
  349. "IP = 127.0.0.1" "IP = 192.168.0.1"
  350. # www.bad.net excluded by parent CA.
  351. ./mkcert.sh req badalt10-key "O = Bad NC Test Certificate 10" \
  352. "1.CN=www.ok.good.com" "2.CN=Joe Bloggs" | \
  353. ./mkcert.sh geneealt badalt10-key badalt10-cert ncca3-key ncca3-cert \
  354. "DNS.1 = www.ok.good.com" "DNS.2 = bad.ok.good.com" \
  355. "email.1 = good@good.org" "email.2 = any@good.com" \
  356. "IP = 127.0.0.1" "IP = 192.168.0.1"
  357. # Certs for CVE-2022-4203 testcase
  358. NC="excluded;otherName:SRVName;UTF8STRING:foo@example.org" ./mkcert.sh genca \
  359. "Test NC CA othername" nccaothername-key nccaothername-cert \
  360. root-key root-cert
  361. ./mkcert.sh req alt-email-key "O = NC email in othername Test Certificate" | \
  362. ./mkcert.sh geneealt bad-othername-key bad-othername-cert \
  363. nccaothername-key nccaothername-cert \
  364. "otherName.1 = SRVName;UTF8STRING:foo@example.org"
  365. # RSA-PSS signatures
  366. # SHA1
  367. ./mkcert.sh genee PSS-SHA1 ee-key ee-pss-sha1-cert ca-key ca-cert \
  368. -sha1 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:digest
  369. # EE SHA256
  370. ./mkcert.sh genee PSS-SHA256 ee-key ee-pss-sha256-cert ca-key ca-cert \
  371. -sha256 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:digest
  372. # CA-PSS
  373. ./mkcert.sh genca "CA-PSS" ca-pss-key ca-pss-cert root-key root-cert \
  374. -sha256 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-1
  375. ./mkcert.sh genee "EE-PSS" ee-key ee-pss-cert ca-pss-key ca-pss-cert \
  376. -sha256 -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:-1
  377. # Should not have been possible to produce, see issue #13968:
  378. #./mkcert.sh genee "EE-PSS-wrong1.5" ee-key ee-pss-wrong1.5-cert ca-pss-key ca-pss-cert -sha256
  379. OPENSSL_KEYALG=ec OPENSSL_KEYBITS=brainpoolP256r1 ./mkcert.sh genee \
  380. "Server ECDSA brainpoolP256r1 cert" server-ecdsa-brainpoolP256r1-key \
  381. server-ecdsa-brainpoolP256r1-cert rootkey rootcert
  382. openssl req -new -noenc -subj "/CN=localhost" \
  383. -newkey rsa-pss -keyout server-pss-restrict-key.pem \
  384. -pkeyopt rsa_pss_keygen_md:sha256 -pkeyopt rsa_pss_keygen_saltlen:32 | \
  385. ./mkcert.sh geneenocsr "Server RSA-PSS restricted cert" \
  386. server-pss-restrict-cert rootkey rootcert
  387. openssl req -new -noenc -subj "/CN=Client-RSA-PSS" \
  388. -newkey rsa-pss -keyout client-pss-restrict-key.pem \
  389. -pkeyopt rsa_pss_keygen_md:sha256 -pkeyopt rsa_pss_keygen_saltlen:32 | \
  390. ./mkcert.sh geneenocsr -p clientAuth "Client RSA-PSS restricted cert" \
  391. client-pss-restrict-cert rootkey rootcert
  392. # CT entry
  393. ./mkcert.sh genct server.example embeddedSCTs1-key embeddedSCTs1 embeddedSCTs1_issuer-key embeddedSCTs1_issuer ct-server-key
  394. OPENSSL_SIGALG= OPENSSL_KEYALG=ed448 ./mkcert.sh genroot "Root Ed448" \
  395. root-ed448-key root-ed448-cert
  396. OPENSSL_SIGALG=ED448 OPENSSL_KEYALG=ed448 ./mkcert.sh genee ed448 \
  397. server-ed448-key server-ed448-cert root-ed448-key root-ed448-cert
  398. # non-critical unknown extension
  399. ./mkcert.sh geneeextra server.example ee-key ee-cert-noncrit-unknown-ext ca-key ca-cert "1.2.3.4=DER:05:00"
  400. # critical unknown extension
  401. ./mkcert.sh geneeextra server.example ee-key ee-cert-crit-unknown-ext ca-key ca-cert "1.2.3.4=critical,DER:05:00"
  402. # critical id-pkix-ocsp-no-check extension
  403. ./mkcert.sh geneeextra server.example ee-key ee-cert-ocsp-nocheck ca-key ca-cert "1.3.6.1.5.5.7.48.1.5=critical,DER:05:00"
  404. # certificatePolicies extension
  405. ./mkcert.sh genca -c "1.3.6.1.4.1.16604.998855.1" "CA" ca-key ca-pol-cert root-key root-cert
  406. ./mkcert.sh geneeextra server.example ee-key ee-cert-policies ca-key ca-cert "certificatePolicies=1.3.6.1.4.1.16604.998855.1"
  407. # We can create a cert with a duplicate policy oid - but its actually invalid!
  408. ./mkcert.sh geneeextra server.example ee-key ee-cert-policies-bad ca-key ca-cert "certificatePolicies=1.3.6.1.4.1.16604.998855.1,1.3.6.1.4.1.16604.998855.1"
  409. # EC cert signed by curve ca with SHA3-224, SHA3-256, SHA3-384, SHA3-512
  410. OPENSSL_SIGALG="sha3-224" ./mkcert.sh genee server.example ee-key-ec-named-named ee-cert-ec-sha3-224 ca-key-ec-named ca-cert-ec-named
  411. OPENSSL_SIGALG="sha3-256" ./mkcert.sh genee server.example ee-key-ec-named-named ee-cert-ec-sha3-256 ca-key-ec-named ca-cert-ec-named
  412. OPENSSL_SIGALG="sha3-384" ./mkcert.sh genee server.example ee-key-ec-named-named ee-cert-ec-sha3-384 ca-key-ec-named ca-cert-ec-named
  413. OPENSSL_SIGALG="sha3-512" ./mkcert.sh genee server.example ee-key-ec-named-named ee-cert-ec-sha3-512 ca-key-ec-named ca-cert-ec-named