25-test_verify.t 21 KB

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