04-client_auth.cnf.in 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 authentication non-empty names
  146. push @tests, {
  147. name => "client-auth-${protocol_name}-require-non-empty-names"
  148. .($sctp ? "-sctp" : ""),
  149. server => {
  150. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  151. "MinProtocol" => $protocol,
  152. "MaxProtocol" => $protocol,
  153. "ClientSignatureAlgorithms" => $clisigalgs,
  154. "ClientCAFile" => test_pem("root-cert.pem"),
  155. "VerifyCAFile" => test_pem("root-cert.pem"),
  156. "VerifyMode" => "Request",
  157. },
  158. client => {
  159. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  160. "MinProtocol" => $protocol,
  161. "MaxProtocol" => $protocol,
  162. "Certificate" => test_pem("ee-client-chain.pem"),
  163. "PrivateKey" => test_pem("ee-key.pem"),
  164. },
  165. test => {
  166. "ExpectedResult" => "Success",
  167. "ExpectedClientCertType" => "RSA",
  168. "ExpectedClientSignType" => $clisigtype,
  169. "ExpectedClientSignHash" => $clihash,
  170. "ExpectedClientCANames" => test_pem("root-cert.pem"),
  171. "Method" => $method,
  172. },
  173. };
  174. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  175. # Handshake with client authentication but without the root certificate.
  176. push @tests, {
  177. name => "client-auth-${protocol_name}-noroot"
  178. .($sctp ? "-sctp" : ""),
  179. server => {
  180. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  181. "MinProtocol" => $protocol,
  182. "MaxProtocol" => $protocol,
  183. "VerifyMode" => "Require",
  184. },
  185. client => {
  186. "CipherString" => "DEFAULT:\@SECLEVEL=0",
  187. "MinProtocol" => $protocol,
  188. "MaxProtocol" => $protocol,
  189. "Certificate" => test_pem("ee-client-chain.pem"),
  190. "PrivateKey" => test_pem("ee-key.pem"),
  191. },
  192. test => {
  193. "ExpectedResult" => "ServerFail",
  194. "ExpectedServerAlert" => $caalert,
  195. "Method" => $method,
  196. },
  197. };
  198. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  199. }
  200. }
  201. }
  202. }
  203. generate_tests();