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