25-test_verify.t 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. use strict;
  9. use warnings;
  10. use File::Spec::Functions qw/canonpath/;
  11. use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/;
  12. use OpenSSL::Test::Utils;
  13. setup("test_verify");
  14. sub verify {
  15. my ($cert, $purpose, $trusted, $untrusted, @opts) = @_;
  16. my @path = qw(test certs);
  17. my @args = qw(openssl verify -auth_level 1);
  18. push(@args, "-purpose", $purpose) if $purpose ne "";
  19. push(@args, @opts);
  20. for (@$trusted) { push(@args, "-trusted", srctop_file(@path, "$_.pem")) }
  21. for (@$untrusted) { push(@args, "-untrusted", srctop_file(@path, "$_.pem")) }
  22. push(@args, srctop_file(@path, "$cert.pem"));
  23. run(app([@args]));
  24. }
  25. plan tests => 155;
  26. # Canonical success
  27. ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]),
  28. "accept compat trust");
  29. # Root CA variants
  30. ok(!verify("ee-cert", "sslserver", [qw(root-nonca)], [qw(ca-cert)]),
  31. "fail trusted non-ca root");
  32. ok(!verify("ee-cert", "sslserver", [qw(nroot+serverAuth)], [qw(ca-cert)]),
  33. "fail server trust non-ca root");
  34. ok(!verify("ee-cert", "sslserver", [qw(nroot+anyEKU)], [qw(ca-cert)]),
  35. "fail wildcard trust non-ca root");
  36. ok(!verify("ee-cert", "sslserver", [qw(root-cert2)], [qw(ca-cert)]),
  37. "fail wrong root key");
  38. ok(!verify("ee-cert", "sslserver", [qw(root-name2)], [qw(ca-cert)]),
  39. "fail wrong root DN");
  40. # Critical extensions
  41. ok(verify("ee-cert-noncrit-unknown-ext", "", ["root-cert"], ["ca-cert"]),
  42. "accept non-critical unknown extension");
  43. ok(!verify("ee-cert-crit-unknown-ext", "", ["root-cert"], ["ca-cert"]),
  44. "reject critical unknown extension");
  45. ok(verify("ee-cert-ocsp-nocheck", "", ["root-cert"], ["ca-cert"]),
  46. "accept critical OCSP No Check");
  47. # Explicit trust/purpose combinations
  48. #
  49. ok(verify("ee-cert", "sslserver", [qw(sroot-cert)], [qw(ca-cert)]),
  50. "accept server purpose");
  51. ok(!verify("ee-cert", "sslserver", [qw(croot-cert)], [qw(ca-cert)]),
  52. "fail client purpose");
  53. ok(verify("ee-cert", "sslserver", [qw(root+serverAuth)], [qw(ca-cert)]),
  54. "accept server trust");
  55. ok(verify("ee-cert", "sslserver", [qw(sroot+serverAuth)], [qw(ca-cert)]),
  56. "accept server trust with server purpose");
  57. ok(verify("ee-cert", "sslserver", [qw(croot+serverAuth)], [qw(ca-cert)]),
  58. "accept server trust with client purpose");
  59. # Wildcard trust
  60. ok(verify("ee-cert", "sslserver", [qw(root+anyEKU)], [qw(ca-cert)]),
  61. "accept wildcard trust");
  62. ok(verify("ee-cert", "sslserver", [qw(sroot+anyEKU)], [qw(ca-cert)]),
  63. "accept wildcard trust with server purpose");
  64. ok(verify("ee-cert", "sslserver", [qw(croot+anyEKU)], [qw(ca-cert)]),
  65. "accept wildcard trust with client purpose");
  66. # Inapplicable mistrust
  67. ok(verify("ee-cert", "sslserver", [qw(root-clientAuth)], [qw(ca-cert)]),
  68. "accept client mistrust");
  69. ok(verify("ee-cert", "sslserver", [qw(sroot-clientAuth)], [qw(ca-cert)]),
  70. "accept client mistrust with server purpose");
  71. ok(!verify("ee-cert", "sslserver", [qw(croot-clientAuth)], [qw(ca-cert)]),
  72. "fail client mistrust with client purpose");
  73. # Inapplicable trust
  74. ok(!verify("ee-cert", "sslserver", [qw(root+clientAuth)], [qw(ca-cert)]),
  75. "fail client trust");
  76. ok(!verify("ee-cert", "sslserver", [qw(sroot+clientAuth)], [qw(ca-cert)]),
  77. "fail client trust with server purpose");
  78. ok(!verify("ee-cert", "sslserver", [qw(croot+clientAuth)], [qw(ca-cert)]),
  79. "fail client trust with client purpose");
  80. # Server mistrust
  81. ok(!verify("ee-cert", "sslserver", [qw(root-serverAuth)], [qw(ca-cert)]),
  82. "fail rejected EKU");
  83. ok(!verify("ee-cert", "sslserver", [qw(sroot-serverAuth)], [qw(ca-cert)]),
  84. "fail server mistrust with server purpose");
  85. ok(!verify("ee-cert", "sslserver", [qw(croot-serverAuth)], [qw(ca-cert)]),
  86. "fail server mistrust with client purpose");
  87. # Wildcard mistrust
  88. ok(!verify("ee-cert", "sslserver", [qw(root-anyEKU)], [qw(ca-cert)]),
  89. "fail wildcard mistrust");
  90. ok(!verify("ee-cert", "sslserver", [qw(sroot-anyEKU)], [qw(ca-cert)]),
  91. "fail wildcard mistrust with server purpose");
  92. ok(!verify("ee-cert", "sslserver", [qw(croot-anyEKU)], [qw(ca-cert)]),
  93. "fail wildcard mistrust with client purpose");
  94. # Check that trusted-first is on by setting up paths to different roots
  95. # depending on whether the intermediate is the trusted or untrusted one.
  96. #
  97. ok(verify("ee-cert", "sslserver", [qw(root-serverAuth root-cert2 ca-root2)],
  98. [qw(ca-cert)]),
  99. "accept trusted-first path");
  100. ok(verify("ee-cert", "sslserver", [qw(root-cert root2+serverAuth ca-root2)],
  101. [qw(ca-cert)]),
  102. "accept trusted-first path with server trust");
  103. ok(!verify("ee-cert", "sslserver", [qw(root-cert root2-serverAuth ca-root2)],
  104. [qw(ca-cert)]),
  105. "fail trusted-first path with server mistrust");
  106. ok(!verify("ee-cert", "sslserver", [qw(root-cert root2+clientAuth ca-root2)],
  107. [qw(ca-cert)]),
  108. "fail trusted-first path with client trust");
  109. # CA variants
  110. ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-nonca)]),
  111. "fail non-CA untrusted intermediate");
  112. ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-nonbc)]),
  113. "fail non-CA untrusted intermediate");
  114. ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-nonca)], []),
  115. "fail non-CA trust-store intermediate");
  116. ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-nonbc)], []),
  117. "fail non-CA trust-store intermediate");
  118. ok(!verify("ee-cert", "sslserver", [qw(root-cert nca+serverAuth)], []),
  119. "fail non-CA server trust intermediate");
  120. ok(!verify("ee-cert", "sslserver", [qw(root-cert nca+anyEKU)], []),
  121. "fail non-CA wildcard trust intermediate");
  122. ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-cert2)]),
  123. "fail wrong intermediate CA key");
  124. ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-name2)]),
  125. "fail wrong intermediate CA DN");
  126. ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-root2)]),
  127. "fail wrong intermediate CA issuer");
  128. ok(!verify("ee-cert", "sslserver", [], [qw(ca-cert)], "-partial_chain"),
  129. "fail untrusted partial chain");
  130. ok(verify("ee-cert", "sslserver", [qw(ca-cert)], [], "-partial_chain"),
  131. "accept trusted partial chain");
  132. ok(!verify("ee-cert", "sslserver", [qw(ca-expired)], [], "-partial_chain"),
  133. "reject expired trusted partial chain"); # this check is beyond RFC 5280
  134. ok(!verify("ee-cert", "sslserver", [qw(root-expired)], [qw(ca-cert)]),
  135. "reject expired trusted root"); # this check is beyond RFC 5280
  136. ok(verify("ee-cert", "sslserver", [qw(sca-cert)], [], "-partial_chain"),
  137. "accept partial chain with server purpose");
  138. ok(!verify("ee-cert", "sslserver", [qw(cca-cert)], [], "-partial_chain"),
  139. "fail partial chain with client purpose");
  140. ok(verify("ee-cert", "sslserver", [qw(ca+serverAuth)], [], "-partial_chain"),
  141. "accept server trust partial chain");
  142. ok(verify("ee-cert", "sslserver", [qw(cca+serverAuth)], [], "-partial_chain"),
  143. "accept server trust client purpose partial chain");
  144. ok(verify("ee-cert", "sslserver", [qw(ca-clientAuth)], [], "-partial_chain"),
  145. "accept client mistrust partial chain");
  146. ok(verify("ee-cert", "sslserver", [qw(ca+anyEKU)], [], "-partial_chain"),
  147. "accept wildcard trust partial chain");
  148. ok(!verify("ee-cert", "sslserver", [], [qw(ca+serverAuth)], "-partial_chain"),
  149. "fail untrusted partial issuer with ignored server trust");
  150. ok(!verify("ee-cert", "sslserver", [qw(ca-serverAuth)], [], "-partial_chain"),
  151. "fail server mistrust partial chain");
  152. ok(!verify("ee-cert", "sslserver", [qw(ca+clientAuth)], [], "-partial_chain"),
  153. "fail client trust partial chain");
  154. ok(!verify("ee-cert", "sslserver", [qw(ca-anyEKU)], [], "-partial_chain"),
  155. "fail wildcard mistrust partial chain");
  156. # We now test auxiliary trust even for intermediate trusted certs without
  157. # -partial_chain. Note that "-trusted_first" is now always on and cannot
  158. # be disabled.
  159. ok(verify("ee-cert", "sslserver", [qw(root-cert ca+serverAuth)], [qw(ca-cert)]),
  160. "accept server trust");
  161. ok(verify("ee-cert", "sslserver", [qw(root-cert ca+anyEKU)], [qw(ca-cert)]),
  162. "accept wildcard trust");
  163. ok(verify("ee-cert", "sslserver", [qw(root-cert sca-cert)], [qw(ca-cert)]),
  164. "accept server purpose");
  165. ok(verify("ee-cert", "sslserver", [qw(root-cert sca+serverAuth)], [qw(ca-cert)]),
  166. "accept server trust and purpose");
  167. ok(verify("ee-cert", "sslserver", [qw(root-cert sca+anyEKU)], [qw(ca-cert)]),
  168. "accept wildcard trust and server purpose");
  169. ok(verify("ee-cert", "sslserver", [qw(root-cert sca-clientAuth)], [qw(ca-cert)]),
  170. "accept client mistrust and server purpose");
  171. ok(verify("ee-cert", "sslserver", [qw(root-cert cca+serverAuth)], [qw(ca-cert)]),
  172. "accept server trust and client purpose");
  173. ok(verify("ee-cert", "sslserver", [qw(root-cert cca+anyEKU)], [qw(ca-cert)]),
  174. "accept wildcard trust and client purpose");
  175. ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-cert)], [qw(ca-cert)]),
  176. "fail client purpose");
  177. ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-anyEKU)], [qw(ca-cert)]),
  178. "fail wildcard mistrust");
  179. ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-serverAuth)], [qw(ca-cert)]),
  180. "fail server mistrust");
  181. ok(!verify("ee-cert", "sslserver", [qw(root-cert ca+clientAuth)], [qw(ca-cert)]),
  182. "fail client trust");
  183. ok(!verify("ee-cert", "sslserver", [qw(root-cert sca+clientAuth)], [qw(ca-cert)]),
  184. "fail client trust and server purpose");
  185. ok(!verify("ee-cert", "sslserver", [qw(root-cert cca+clientAuth)], [qw(ca-cert)]),
  186. "fail client trust and client purpose");
  187. ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-serverAuth)], [qw(ca-cert)]),
  188. "fail server mistrust and client purpose");
  189. ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-clientAuth)], [qw(ca-cert)]),
  190. "fail client mistrust and client purpose");
  191. ok(!verify("ee-cert", "sslserver", [qw(root-cert sca-serverAuth)], [qw(ca-cert)]),
  192. "fail server mistrust and server purpose");
  193. ok(!verify("ee-cert", "sslserver", [qw(root-cert sca-anyEKU)], [qw(ca-cert)]),
  194. "fail wildcard mistrust and server purpose");
  195. ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-anyEKU)], [qw(ca-cert)]),
  196. "fail wildcard mistrust and client purpose");
  197. # EE variants
  198. ok(verify("ee-client", "sslclient", [qw(root-cert)], [qw(ca-cert)]),
  199. "accept client chain");
  200. ok(!verify("ee-client", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
  201. "fail server leaf purpose");
  202. ok(!verify("ee-cert", "sslclient", [qw(root-cert)], [qw(ca-cert)]),
  203. "fail client leaf purpose");
  204. ok(!verify("ee-cert2", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
  205. "fail wrong intermediate CA key");
  206. ok(!verify("ee-name2", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
  207. "fail wrong intermediate CA DN");
  208. ok(!verify("ee-expired", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
  209. "fail expired leaf");
  210. ok(verify("ee-cert", "sslserver", [qw(ee-cert)], [], "-partial_chain"),
  211. "accept last-resort direct leaf match");
  212. ok(verify("ee-client", "sslclient", [qw(ee-client)], [], "-partial_chain"),
  213. "accept last-resort direct leaf match");
  214. ok(!verify("ee-cert", "sslserver", [qw(ee-client)], [], "-partial_chain"),
  215. "fail last-resort direct leaf non-match");
  216. ok(verify("ee-cert", "sslserver", [qw(ee+serverAuth)], [], "-partial_chain"),
  217. "accept direct match with server trust");
  218. ok(!verify("ee-cert", "sslserver", [qw(ee-serverAuth)], [], "-partial_chain"),
  219. "fail direct match with server mistrust");
  220. ok(verify("ee-client", "sslclient", [qw(ee+clientAuth)], [], "-partial_chain"),
  221. "accept direct match with client trust");
  222. ok(!verify("ee-client", "sslclient", [qw(ee-clientAuth)], [], "-partial_chain"),
  223. "reject direct match with client mistrust");
  224. ok(verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
  225. "accept non-ca with pathlen:0 by default");
  226. ok(!verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)], "-x509_strict"),
  227. "reject non-ca with pathlen:0 with strict flag");
  228. # Proxy certificates
  229. ok(!verify("pc1-cert", "sslclient", [qw(root-cert)], [qw(ee-client ca-cert)]),
  230. "fail to accept proxy cert without -allow_proxy_certs");
  231. ok(verify("pc1-cert", "sslclient", [qw(root-cert)], [qw(ee-client ca-cert)],
  232. "-allow_proxy_certs"),
  233. "accept proxy cert 1");
  234. ok(verify("pc2-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
  235. "-allow_proxy_certs"),
  236. "accept proxy cert 2");
  237. ok(!verify("bad-pc3-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
  238. "-allow_proxy_certs"),
  239. "fail proxy cert with incorrect subject");
  240. ok(!verify("bad-pc4-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
  241. "-allow_proxy_certs"),
  242. "fail proxy cert with incorrect pathlen");
  243. ok(verify("pc5-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
  244. "-allow_proxy_certs"),
  245. "accept proxy cert missing proxy policy");
  246. ok(!verify("pc6-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
  247. "-allow_proxy_certs"),
  248. "failed proxy cert where last CN was added as a multivalue RDN component");
  249. # Security level tests
  250. ok(verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "2"),
  251. "accept RSA 2048 chain at auth level 2");
  252. ok(!verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "3"),
  253. "reject RSA 2048 root at auth level 3");
  254. ok(verify("ee-cert", "", ["root-cert-768"], ["ca-cert-768i"], "-auth_level", "0"),
  255. "accept RSA 768 root at auth level 0");
  256. ok(!verify("ee-cert", "", ["root-cert-768"], ["ca-cert-768i"]),
  257. "reject RSA 768 root at auth level 1");
  258. ok(verify("ee-cert-768i", "", ["root-cert"], ["ca-cert-768"], "-auth_level", "0"),
  259. "accept RSA 768 intermediate at auth level 0");
  260. ok(!verify("ee-cert-768i", "", ["root-cert"], ["ca-cert-768"]),
  261. "reject RSA 768 intermediate at auth level 1");
  262. ok(verify("ee-cert-768", "", ["root-cert"], ["ca-cert"], "-auth_level", "0"),
  263. "accept RSA 768 leaf at auth level 0");
  264. ok(!verify("ee-cert-768", "", ["root-cert"], ["ca-cert"]),
  265. "reject RSA 768 leaf at auth level 1");
  266. #
  267. ok(verify("ee-cert", "", ["root-cert-md5"], ["ca-cert"], "-auth_level", "2"),
  268. "accept md5 self-signed TA at auth level 2");
  269. ok(verify("ee-cert", "", ["ca-cert-md5-any"], [], "-auth_level", "2"),
  270. "accept md5 intermediate TA at auth level 2");
  271. ok(verify("ee-cert", "", ["root-cert"], ["ca-cert-md5"], "-auth_level", "0"),
  272. "accept md5 intermediate at auth level 0");
  273. ok(!verify("ee-cert", "", ["root-cert"], ["ca-cert-md5"]),
  274. "reject md5 intermediate at auth level 1");
  275. ok(verify("ee-cert-md5", "", ["root-cert"], ["ca-cert"], "-auth_level", "0"),
  276. "accept md5 leaf at auth level 0");
  277. ok(!verify("ee-cert-md5", "", ["root-cert"], ["ca-cert"]),
  278. "reject md5 leaf at auth level 1");
  279. # Explicit vs named curve tests
  280. SKIP: {
  281. skip "EC is not supported by this OpenSSL build", 3
  282. if disabled("ec");
  283. ok(!verify("ee-cert-ec-explicit", "", ["root-cert"],
  284. ["ca-cert-ec-named"]),
  285. "reject explicit curve leaf with named curve intermediate");
  286. ok(!verify("ee-cert-ec-named-explicit", "", ["root-cert"],
  287. ["ca-cert-ec-explicit"]),
  288. "reject named curve leaf with explicit curve intermediate");
  289. ok(verify("ee-cert-ec-named-named", "", ["root-cert"],
  290. ["ca-cert-ec-named"]),
  291. "accept named curve leaf with named curve intermediate");
  292. }
  293. # Depth tests, note the depth limit bounds the number of CA certificates
  294. # between the trust-anchor and the leaf, so, for example, with a root->ca->leaf
  295. # chain, depth = 1 is sufficient, but depth == 0 is not.
  296. #
  297. ok(verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-verify_depth", "2"),
  298. "accept chain with verify_depth 2");
  299. ok(verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-verify_depth", "1"),
  300. "accept chain with verify_depth 1");
  301. ok(!verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-verify_depth", "0"),
  302. "reject chain with verify_depth 0");
  303. ok(verify("ee-cert", "", ["ca-cert-md5-any"], [], "-verify_depth", "0"),
  304. "accept md5 intermediate TA with verify_depth 0");
  305. # Name Constraints tests.
  306. ok(verify("alt1-cert", "", ["root-cert"], ["ncca1-cert"], ),
  307. "Name Constraints everything permitted");
  308. ok(verify("alt2-cert", "", ["root-cert"], ["ncca2-cert"], ),
  309. "Name Constraints nothing excluded");
  310. ok(verify("alt3-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
  311. "Name Constraints nested test all permitted");
  312. ok(verify("goodcn1-cert", "", ["root-cert"], ["ncca1-cert"], ),
  313. "Name Constraints CNs permitted");
  314. ok(!verify("badcn1-cert", "", ["root-cert"], ["ncca1-cert"], ),
  315. "Name Constraints CNs not permitted");
  316. ok(!verify("badalt1-cert", "", ["root-cert"], ["ncca1-cert"], ),
  317. "Name Constraints hostname not permitted");
  318. ok(!verify("badalt2-cert", "", ["root-cert"], ["ncca2-cert"], ),
  319. "Name Constraints hostname excluded");
  320. ok(!verify("badalt3-cert", "", ["root-cert"], ["ncca1-cert"], ),
  321. "Name Constraints email address not permitted");
  322. ok(!verify("badalt4-cert", "", ["root-cert"], ["ncca1-cert"], ),
  323. "Name Constraints subject email address not permitted");
  324. ok(!verify("badalt5-cert", "", ["root-cert"], ["ncca1-cert"], ),
  325. "Name Constraints IP address not permitted");
  326. ok(!verify("badalt6-cert", "", ["root-cert"], ["ncca1-cert"], ),
  327. "Name Constraints CN hostname not permitted");
  328. ok(!verify("badalt7-cert", "", ["root-cert"], ["ncca1-cert"], ),
  329. "Name Constraints CN BMPSTRING hostname not permitted");
  330. ok(!verify("badalt8-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
  331. "Name constraints nested DNS name not permitted 1");
  332. ok(!verify("badalt9-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
  333. "Name constraints nested DNS name not permitted 2");
  334. ok(!verify("badalt10-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
  335. "Name constraints nested DNS name excluded");
  336. ok(verify("ee-pss-sha1-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "0"),
  337. "Accept PSS signature using SHA1 at auth level 0");
  338. ok(verify("ee-pss-sha256-cert", "", ["root-cert"], ["ca-cert"], ),
  339. "CA with PSS signature using SHA256");
  340. ok(!verify("ee-pss-sha1-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "1"),
  341. "Reject PSS signature using SHA1 and auth level 1");
  342. ok(verify("ee-pss-sha256-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "2"),
  343. "PSS signature using SHA256 and auth level 2");
  344. ok(verify("ee-pss-cert", "", ["root-cert"], ["ca-pss-cert"], ),
  345. "CA PSS signature");
  346. ok(!verify("ee-pss-wrong1.5-cert", "", ["root-cert"], ["ca-pss-cert"], ),
  347. "CA producing regular PKCS#1 v1.5 signature with PSA-PSS key");
  348. ok(!verify("many-names1", "", ["many-constraints"], ["many-constraints"], ),
  349. "Too many names and constraints to check (1)");
  350. ok(!verify("many-names2", "", ["many-constraints"], ["many-constraints"], ),
  351. "Too many names and constraints to check (2)");
  352. ok(!verify("many-names3", "", ["many-constraints"], ["many-constraints"], ),
  353. "Too many names and constraints to check (3)");
  354. ok(verify("some-names1", "", ["many-constraints"], ["many-constraints"], ),
  355. "Not too many names and constraints to check (1)");
  356. ok(verify("some-names2", "", ["many-constraints"], ["many-constraints"], ),
  357. "Not too many names and constraints to check (2)");
  358. ok(verify("some-names2", "", ["many-constraints"], ["many-constraints"], ),
  359. "Not too many names and constraints to check (3)");
  360. ok(verify("root-cert-rsa2", "", ["root-cert-rsa2"], [], "-check_ss_sig"),
  361. "Public Key Algorithm rsa instead of rsaEncryption");
  362. ok(verify("ee-self-signed", "", ["ee-self-signed"], [], "-attime", "1593565200"),
  363. "accept trusted self-signed EE cert excluding key usage keyCertSign");
  364. SKIP: {
  365. skip "Ed25519 is not supported by this OpenSSL build", 6
  366. if disabled("ec");
  367. # ED25519 certificate from draft-ietf-curdle-pkix-04
  368. ok(verify("ee-ed25519", "", ["root-ed25519"], []),
  369. "accept X25519 EE cert issued by trusted Ed25519 self-signed CA cert");
  370. ok(!verify("ee-ed25519", "", ["root-ed25519"], [], "-x509_strict"),
  371. "reject X25519 EE cert in strict mode since AKID is missing");
  372. ok(!verify("root-ed25519", "", ["ee-ed25519"], []),
  373. "fail Ed25519 CA and EE certs swapped");
  374. ok(verify("root-ed25519", "", ["root-ed25519"], []),
  375. "accept trusted Ed25519 self-signed CA cert");
  376. ok(!verify("ee-ed25519", "", ["ee-ed25519"], []),
  377. "fail trusted Ed25519-signed self-issued X25519 cert");
  378. ok(verify("ee-ed25519", "", ["ee-ed25519"], [], "-partial_chain"),
  379. "accept last-resort direct leaf match Ed25519-signed self-issued cert");
  380. }
  381. SKIP: {
  382. skip "SM2 is not supported by this OpenSSL build", 2 if disabled("sm2");
  383. ok_nofips(verify("sm2", "", ["sm2-ca-cert"], [], "-vfyopt", "distid:1234567812345678"),
  384. "SM2 ID test");
  385. ok_nofips(verify("sm2", "", ["sm2-ca-cert"], [], "-vfyopt", "hexdistid:31323334353637383132333435363738"),
  386. "SM2 hex ID test");
  387. }