michael@0: // -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: // This Source Code Form is subject to the terms of the Mozilla Public michael@0: // License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: // file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: "use strict"; michael@0: michael@0: // In which we connect to a server that staples an OCSP response for a michael@0: // certificate signed by an intermediate that has an OCSP AIA to ensure michael@0: // that an OCSP request is not made for the intermediate. michael@0: michael@0: let gOCSPRequestCount = 0; michael@0: michael@0: function add_ocsp_test(aHost, aExpectedResult) { michael@0: add_connection_test(aHost, aExpectedResult, michael@0: function() { michael@0: clearOCSPCache(); michael@0: clearSessionCache(); michael@0: }); michael@0: } michael@0: michael@0: function run_test() { michael@0: do_get_profile(); michael@0: Services.prefs.setBoolPref("security.ssl.enable_ocsp_stapling", true); michael@0: michael@0: let ocspResponder = new HttpServer(); michael@0: ocspResponder.registerPrefixHandler("/", function(request, response) { michael@0: gOCSPRequestCount++; michael@0: response.setStatusLine(request.httpVersion, 500, "Internal Server Error"); michael@0: let body = "Refusing to return a response"; michael@0: response.bodyOutputStream.write(body, body.length); michael@0: }); michael@0: ocspResponder.start(8080); michael@0: michael@0: add_tls_server_setup("OCSPStaplingServer"); michael@0: michael@0: add_tests_in_mode(true); michael@0: add_tests_in_mode(false); michael@0: michael@0: add_test(function () { ocspResponder.stop(run_next_test); }); michael@0: add_test(function() { michael@0: do_check_eq(gOCSPRequestCount, 0); michael@0: run_next_test(); michael@0: }); michael@0: run_next_test(); michael@0: } michael@0: michael@0: function add_tests_in_mode(useMozillaPKIX) { michael@0: add_test(function () { michael@0: Services.prefs.setBoolPref("security.use_mozillapkix_verification", michael@0: useMozillaPKIX); michael@0: run_next_test(); michael@0: }); michael@0: michael@0: add_ocsp_test("ocsp-stapling-with-intermediate.example.com", Cr.NS_OK); michael@0: }