04-client_auth.conf.in 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. # We test version-flexible negotiation (undef) and each protocol version.
  10. my @protocols = (undef, "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "DTLSv1", "DTLSv1.2");
  11. my @is_disabled = (0);
  12. push @is_disabled, anydisabled("ssl3", "tls1", "tls1_1", "tls1_2", "dtls1", "dtls1_2");
  13. our @tests = ();
  14. sub generate_tests() {
  15. foreach (0..$#protocols) {
  16. my $protocol = $protocols[$_];
  17. my $protocol_name = $protocol || "flex";
  18. my $caalert;
  19. my $method;
  20. my $sctpenabled = 0;
  21. if (!$is_disabled[$_]) {
  22. if ($protocol_name eq "SSLv3") {
  23. $caalert = "BadCertificate";
  24. } else {
  25. $caalert = "UnknownCA";
  26. }
  27. if ($protocol_name =~ m/^DTLS/) {
  28. $method = "DTLS";
  29. $sctpenabled = 1 if !disabled("sctp");
  30. }
  31. my $clihash;
  32. my $clisigtype;
  33. my $clisigalgs;
  34. # TODO(TLS1.3) add TLSv1.3 versions
  35. if ($protocol_name eq "TLSv1.2") {
  36. $clihash = "SHA256";
  37. $clisigtype = "RSA";
  38. $clisigalgs = "SHA256+RSA";
  39. }
  40. for (my $sctp = 0; $sctp <= $sctpenabled; $sctp++) {
  41. # Sanity-check simple handshake.
  42. push @tests, {
  43. name => "server-auth-${protocol_name}"
  44. .($sctp ? "-sctp" : ""),
  45. server => {
  46. "MinProtocol" => $protocol,
  47. "MaxProtocol" => $protocol
  48. },
  49. client => {
  50. "MinProtocol" => $protocol,
  51. "MaxProtocol" => $protocol
  52. },
  53. test => {
  54. "ExpectedResult" => "Success",
  55. "Method" => $method,
  56. },
  57. };
  58. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  59. # Handshake with client cert requested but not required or received.
  60. push @tests, {
  61. name => "client-auth-${protocol_name}-request"
  62. .($sctp ? "-sctp" : ""),
  63. server => {
  64. "MinProtocol" => $protocol,
  65. "MaxProtocol" => $protocol,
  66. "VerifyMode" => "Request"
  67. },
  68. client => {
  69. "MinProtocol" => $protocol,
  70. "MaxProtocol" => $protocol
  71. },
  72. test => {
  73. "ExpectedResult" => "Success",
  74. "Method" => $method,
  75. },
  76. };
  77. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  78. # Handshake with client cert required but not present.
  79. push @tests, {
  80. name => "client-auth-${protocol_name}-require-fail"
  81. .($sctp ? "-sctp" : ""),
  82. server => {
  83. "MinProtocol" => $protocol,
  84. "MaxProtocol" => $protocol,
  85. "VerifyCAFile" => test_pem("root-cert.pem"),
  86. "VerifyMode" => "Require",
  87. },
  88. client => {
  89. "MinProtocol" => $protocol,
  90. "MaxProtocol" => $protocol
  91. },
  92. test => {
  93. "ExpectedResult" => "ServerFail",
  94. "ExpectedServerAlert" => "HandshakeFailure",
  95. "Method" => $method,
  96. },
  97. };
  98. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  99. # Successful handshake with client authentication.
  100. push @tests, {
  101. name => "client-auth-${protocol_name}-require"
  102. .($sctp ? "-sctp" : ""),
  103. server => {
  104. "MinProtocol" => $protocol,
  105. "MaxProtocol" => $protocol,
  106. "ClientSignatureAlgorithms" => $clisigalgs,
  107. "VerifyCAFile" => test_pem("root-cert.pem"),
  108. "VerifyMode" => "Request",
  109. },
  110. client => {
  111. "MinProtocol" => $protocol,
  112. "MaxProtocol" => $protocol,
  113. "Certificate" => test_pem("ee-client-chain.pem"),
  114. "PrivateKey" => test_pem("ee-key.pem"),
  115. },
  116. test => {
  117. "ExpectedResult" => "Success",
  118. "ExpectedClientCertType" => "RSA",
  119. "ExpectedClientSignType" => $clisigtype,
  120. "ExpectedClientSignHash" => $clihash,
  121. "ExpectedClientCANames" => "empty",
  122. "Method" => $method,
  123. },
  124. };
  125. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  126. # Successful handshake with client authentication non-empty names
  127. push @tests, {
  128. name => "client-auth-${protocol_name}-require-non-empty-names"
  129. .($sctp ? "-sctp" : ""),
  130. server => {
  131. "MinProtocol" => $protocol,
  132. "MaxProtocol" => $protocol,
  133. "ClientSignatureAlgorithms" => $clisigalgs,
  134. "ClientCAFile" => test_pem("root-cert.pem"),
  135. "VerifyCAFile" => test_pem("root-cert.pem"),
  136. "VerifyMode" => "Request",
  137. },
  138. client => {
  139. "MinProtocol" => $protocol,
  140. "MaxProtocol" => $protocol,
  141. "Certificate" => test_pem("ee-client-chain.pem"),
  142. "PrivateKey" => test_pem("ee-key.pem"),
  143. },
  144. test => {
  145. "ExpectedResult" => "Success",
  146. "ExpectedClientCertType" => "RSA",
  147. "ExpectedClientSignType" => $clisigtype,
  148. "ExpectedClientSignHash" => $clihash,
  149. "ExpectedClientCANames" => test_pem("root-cert.pem"),
  150. "Method" => $method,
  151. },
  152. };
  153. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  154. # Handshake with client authentication but without the root certificate.
  155. push @tests, {
  156. name => "client-auth-${protocol_name}-noroot"
  157. .($sctp ? "-sctp" : ""),
  158. server => {
  159. "MinProtocol" => $protocol,
  160. "MaxProtocol" => $protocol,
  161. "VerifyMode" => "Require",
  162. },
  163. client => {
  164. "MinProtocol" => $protocol,
  165. "MaxProtocol" => $protocol,
  166. "Certificate" => test_pem("ee-client-chain.pem"),
  167. "PrivateKey" => test_pem("ee-key.pem"),
  168. },
  169. test => {
  170. "ExpectedResult" => "ServerFail",
  171. "ExpectedServerAlert" => $caalert,
  172. "Method" => $method,
  173. },
  174. };
  175. $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
  176. }
  177. }
  178. }
  179. }
  180. generate_tests();