04-client_auth.cnf.in 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. # -*- mode: perl; -*-
  2. ## SSL test configurations
  3. package ssltests;
  4. use strict;
  5. use warnings;
  6. use OpenSSL::Test;
  7. use OpenSSL::Test::Utils qw(anydisabled disabled);
  8. setup("no_test_here");
  9. our $fips_mode;
  10. my @protocols;
  11. my @is_disabled = (0);
  12. # We test version-flexible negotiation (undef) and each protocol version.
  13. if ($fips_mode) {
  14. @protocols = (undef, "TLSv1.2", "DTLSv1.2");
  15. push @is_disabled, anydisabled("tls1_2", "dtls1_2");
  16. } else {
  17. @protocols = (undef, "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "DTLSv1", "DTLSv1.2");
  18. push @is_disabled, anydisabled("ssl3", "tls1", "tls1_1", "tls1_2", "dtls1", "dtls1_2");
  19. }
  20. our @tests = ();
  21. sub generate_tests() {
  22. foreach (0..$#protocols) {
  23. my $protocol = $protocols[$_];
  24. my $protocol_name = $protocol || "flex";
  25. my $caalert;
  26. my $method;
  27. my $sctpenabled = 0;
  28. if (!$is_disabled[$_]) {
  29. if ($protocol_name eq "SSLv3") {
  30. $caalert = "BadCertificate";
  31. } else {
  32. $caalert = "UnknownCA";
  33. }
  34. if ($protocol_name =~ m/^DTLS/) {
  35. $method = "DTLS";
  36. $sctpenabled = 1 if !disabled("sctp");
  37. }
  38. my $clihash;
  39. my $clisigtype;
  40. my $clisigalgs;
  41. # TODO(TLS1.3) add TLSv1.3 versions
  42. if ($protocol_name eq "TLSv1.2") {
  43. $clihash = "SHA256";
  44. $clisigtype = "RSA";
  45. $clisigalgs = "SHA256+RSA";
  46. }
  47. for (my $sctp = 0; $sctp <= $sctpenabled; $sctp++) {
  48. # Sanity-check simple handshake.
  49. push @tests, {
  50. name => "server-auth-${protocol_name}"
  51. .($sctp ? "-sctp" : ""),
  52. server => {
  53. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  54. "MinProtocol" => $protocol,
  55. "MaxProtocol" => $protocol
  56. },
  57. client => {
  58. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  59. "MinProtocol" => $protocol,
  60. "MaxProtocol" => $protocol
  61. },
  62. test => {
  63. "ExpectedResult" => "Success",
  64. "Method" => $method,
  65. },
  66. };
  67. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  68. # Handshake with client cert requested but not required or received.
  69. push @tests, {
  70. name => "client-auth-${protocol_name}-request"
  71. .($sctp ? "-sctp" : ""),
  72. server => {
  73. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  74. "MinProtocol" => $protocol,
  75. "MaxProtocol" => $protocol,
  76. "VerifyMode" => "Request"
  77. },
  78. client => {
  79. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  80. "MinProtocol" => $protocol,
  81. "MaxProtocol" => $protocol
  82. },
  83. test => {
  84. "ExpectedResult" => "Success",
  85. "Method" => $method,
  86. },
  87. };
  88. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  89. # Handshake with client cert required but not present.
  90. push @tests, {
  91. name => "client-auth-${protocol_name}-require-fail"
  92. .($sctp ? "-sctp" : ""),
  93. server => {
  94. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  95. "MinProtocol" => $protocol,
  96. "MaxProtocol" => $protocol,
  97. "VerifyCAFile" => test_pem("root-cert.pem"),
  98. "VerifyMode" => "Require",
  99. },
  100. client => {
  101. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  102. "MinProtocol" => $protocol,
  103. "MaxProtocol" => $protocol
  104. },
  105. test => {
  106. "ExpectedResult" => "ServerFail",
  107. "ExpectedServerAlert" =>
  108. ($protocol_name eq "flex"
  109. && !disabled("tls1_3")
  110. && (!disabled("ec") || !disabled("dh")))
  111. ? "CertificateRequired" : "HandshakeFailure",
  112. "Method" => $method,
  113. },
  114. };
  115. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  116. # Successful handshake with client authentication.
  117. push @tests, {
  118. name => "client-auth-${protocol_name}-require"
  119. .($sctp ? "-sctp" : ""),
  120. server => {
  121. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  122. "MinProtocol" => $protocol,
  123. "MaxProtocol" => $protocol,
  124. "ClientSignatureAlgorithms" => $clisigalgs,
  125. "VerifyCAFile" => test_pem("root-cert.pem"),
  126. "VerifyMode" => "Request",
  127. },
  128. client => {
  129. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  130. "MinProtocol" => $protocol,
  131. "MaxProtocol" => $protocol,
  132. "Certificate" => test_pem("ee-client-chain.pem"),
  133. "PrivateKey" => test_pem("ee-key.pem"),
  134. },
  135. test => {
  136. "ExpectedResult" => "Success",
  137. "ExpectedClientCertType" => "RSA",
  138. "ExpectedClientSignType" => $clisigtype,
  139. "ExpectedClientSignHash" => $clihash,
  140. "ExpectedClientCANames" => "empty",
  141. "Method" => $method,
  142. },
  143. };
  144. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  145. # Successful handshake with client RSA-PSS cert, StrictCertCheck
  146. push @tests, {
  147. name => "client-auth-${protocol_name}-rsa-pss"
  148. .($sctp ? "-sctp" : ""),
  149. server => {
  150. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  151. "MinProtocol" => $protocol,
  152. "MaxProtocol" => $protocol,
  153. "ClientCAFile" => test_pem("rootcert.pem"),
  154. "VerifyCAFile" => test_pem("rootcert.pem"),
  155. "VerifyMode" => "Require",
  156. },
  157. client => {
  158. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  159. "MinProtocol" => $protocol,
  160. "MaxProtocol" => $protocol,
  161. "Certificate" => test_pem("client-pss-restrict-cert.pem"),
  162. "PrivateKey" => test_pem("client-pss-restrict-key.pem"),
  163. "Options" => "StrictCertCheck",
  164. },
  165. test => {
  166. "ExpectedResult" => "Success",
  167. "ExpectedClientCertType" => "RSA-PSS",
  168. "ExpectedClientCANames" => test_pem("rootcert.pem"),
  169. "Method" => $method,
  170. },
  171. } if $protocol_name eq "TLSv1.2" || $protocol_name eq "flex";
  172. # Failed handshake with client RSA-PSS cert, StrictCertCheck, bad CA
  173. push @tests, {
  174. name => "client-auth-${protocol_name}-rsa-pss-bad"
  175. .($sctp ? "-sctp" : ""),
  176. server => {
  177. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  178. "MinProtocol" => $protocol,
  179. "MaxProtocol" => $protocol,
  180. "ClientCAFile" => test_pem("rootCA.pem"),
  181. "VerifyCAFile" => test_pem("rootCA.pem"),
  182. "VerifyMode" => "Require",
  183. },
  184. client => {
  185. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  186. "MinProtocol" => $protocol,
  187. "MaxProtocol" => $protocol,
  188. "Certificate" => test_pem("client-pss-restrict-cert.pem"),
  189. "PrivateKey" => test_pem("client-pss-restrict-key.pem"),
  190. "Options" => "StrictCertCheck",
  191. },
  192. test => {
  193. "ExpectedResult" => "ServerFail",
  194. "ExpectedServerAlert" =>
  195. ($protocol_name eq "flex"
  196. && !disabled("tls1_3")
  197. && (!disabled("ec") || !disabled("dh")))
  198. ? "CertificateRequired" : "HandshakeFailure",
  199. "Method" => $method,
  200. },
  201. } if $protocol_name eq "TLSv1.2" || $protocol_name eq "flex";
  202. # Successful handshake with client authentication non-empty names
  203. push @tests, {
  204. name => "client-auth-${protocol_name}-require-non-empty-names"
  205. .($sctp ? "-sctp" : ""),
  206. server => {
  207. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  208. "MinProtocol" => $protocol,
  209. "MaxProtocol" => $protocol,
  210. "ClientSignatureAlgorithms" => $clisigalgs,
  211. "ClientCAFile" => test_pem("root-cert.pem"),
  212. "VerifyCAFile" => test_pem("root-cert.pem"),
  213. "VerifyMode" => "Request",
  214. },
  215. client => {
  216. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  217. "MinProtocol" => $protocol,
  218. "MaxProtocol" => $protocol,
  219. "Certificate" => test_pem("ee-client-chain.pem"),
  220. "PrivateKey" => test_pem("ee-key.pem"),
  221. },
  222. test => {
  223. "ExpectedResult" => "Success",
  224. "ExpectedClientCertType" => "RSA",
  225. "ExpectedClientSignType" => $clisigtype,
  226. "ExpectedClientSignHash" => $clihash,
  227. "ExpectedClientCANames" => test_pem("root-cert.pem"),
  228. "Method" => $method,
  229. },
  230. };
  231. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  232. # Handshake with client authentication but without the root certificate.
  233. push @tests, {
  234. name => "client-auth-${protocol_name}-noroot"
  235. .($sctp ? "-sctp" : ""),
  236. server => {
  237. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  238. "MinProtocol" => $protocol,
  239. "MaxProtocol" => $protocol,
  240. "VerifyMode" => "Require",
  241. },
  242. client => {
  243. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  244. "MinProtocol" => $protocol,
  245. "MaxProtocol" => $protocol,
  246. "Certificate" => test_pem("ee-client-chain.pem"),
  247. "PrivateKey" => test_pem("ee-key.pem"),
  248. },
  249. test => {
  250. "ExpectedResult" => "ServerFail",
  251. "ExpectedServerAlert" => $caalert,
  252. "Method" => $method,
  253. },
  254. };
  255. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  256. }
  257. }
  258. }
  259. }
  260. generate_tests();