Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 "use strict";
7 // In which we connect to a server that staples an OCSP response for a
8 // certificate signed by an intermediate that has an OCSP AIA to ensure
9 // that an OCSP request is not made for the intermediate.
11 let gOCSPRequestCount = 0;
13 function add_ocsp_test(aHost, aExpectedResult) {
14 add_connection_test(aHost, aExpectedResult,
15 function() {
16 clearOCSPCache();
17 clearSessionCache();
18 });
19 }
21 function run_test() {
22 do_get_profile();
23 Services.prefs.setBoolPref("security.ssl.enable_ocsp_stapling", true);
25 let ocspResponder = new HttpServer();
26 ocspResponder.registerPrefixHandler("/", function(request, response) {
27 gOCSPRequestCount++;
28 response.setStatusLine(request.httpVersion, 500, "Internal Server Error");
29 let body = "Refusing to return a response";
30 response.bodyOutputStream.write(body, body.length);
31 });
32 ocspResponder.start(8080);
34 add_tls_server_setup("OCSPStaplingServer");
36 add_tests_in_mode(true);
37 add_tests_in_mode(false);
39 add_test(function () { ocspResponder.stop(run_next_test); });
40 add_test(function() {
41 do_check_eq(gOCSPRequestCount, 0);
42 run_next_test();
43 });
44 run_next_test();
45 }
47 function add_tests_in_mode(useMozillaPKIX) {
48 add_test(function () {
49 Services.prefs.setBoolPref("security.use_mozillapkix_verification",
50 useMozillaPKIX);
51 run_next_test();
52 });
54 add_ocsp_test("ocsp-stapling-with-intermediate.example.com", Cr.NS_OK);
55 }