tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_ocsp_stapling_with_intermediate.js (1515B)


      1 // -*- indent-tabs-mode: nil; js-indent-level: 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";
      6 
      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.
     10 
     11 var gOCSPRequestCount = 0;
     12 
     13 function add_ocsp_test(aHost, aExpectedResult) {
     14  add_connection_test(aHost, aExpectedResult, function () {
     15    clearOCSPCache();
     16    clearSessionCache();
     17  });
     18 }
     19 
     20 function run_test() {
     21  do_get_profile();
     22  Services.prefs.setBoolPref("security.ssl.enable_ocsp_stapling", true);
     23 
     24  let ocspResponder = new HttpServer();
     25  ocspResponder.registerPrefixHandler("/", function (request, response) {
     26    gOCSPRequestCount++;
     27    response.setStatusLine(request.httpVersion, 500, "Internal Server Error");
     28    let body = "Refusing to return a response";
     29    response.bodyOutputStream.write(body, body.length);
     30  });
     31  ocspResponder.start(8888);
     32 
     33  add_tls_server_setup("OCSPStaplingServer", "ocsp_certs");
     34 
     35  add_ocsp_test(
     36    "ocsp-stapling-with-intermediate.example.com",
     37    PRErrorCodeSuccess
     38  );
     39 
     40  add_test(function () {
     41    ocspResponder.stop(run_next_test);
     42  });
     43  add_test(function () {
     44    equal(gOCSPRequestCount, 0, "No OCSP requests should have been made");
     45    run_next_test();
     46  });
     47  run_next_test();
     48 }