function _setupTLSServerTest(serverBinName)
{
  let certdb = Cc["@mozilla.org/security/x509certdb;1"]
                  .getService(Ci.nsIX509CertDB);
  // The trusted CA that is typically used for "good" certificates.
  addCertFromFile(certdb, "tlsserver/test-ca.der", "CTu,u,u");

  const CALLBACK_PORT = 8444;

  let directoryService = Cc["@mozilla.org/file/directory_service;1"]
                           .getService(Ci.nsIProperties);
  let envSvc = Cc["@mozilla.org/process/environment;1"]
                 .getService(Ci.nsIEnvironment);
  let greDir = directoryService.get("GreD", Ci.nsIFile);
  envSvc.set("DYLD_LIBRARY_PATH", greDir.path);
  envSvc.set("LD_LIBRARY_PATH", greDir.path);
  envSvc.set("MOZ_TLS_SERVER_DEBUG_LEVEL", "3");
  envSvc.set("MOZ_TLS_SERVER_CALLBACK_PORT", CALLBACK_PORT);

  let httpServer = new HttpServer();
  httpServer.registerPathHandler("/",
      function handleServerCallback(aRequest, aResponse) {
        aResponse.setStatusLine(aRequest.httpVersion, 200, "OK");
        aResponse.setHeader("Content-Type", "text/plain");
        let responseBody = "OK!";
        aResponse.bodyOutputStream.write(responseBody, responseBody.length);
        do_execute_soon(function() {
          httpServer.stop(run_next_test);
        });
      });
  httpServer.start(CALLBACK_PORT);

  let serverBin = _getBinaryUtil(serverBinName);
  let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
  process.init(serverBin);
  let certDir = directoryService.get("CurWorkD", Ci.nsILocalFile);
  certDir.append("tlsserver");
  do_check_true(certDir.exists());
  // Using "sql:" causes the SQL DB to be used so we can run tests on Android.
  process.run(false, [ "sql:" + certDir.path ], 1);

  do_register_cleanup(function() {
    process.kill();
  });
}
// Do not call this directly; use add_tls_server_setup
Do not call this directly; use add_tls_server_setup
Do not call this directly ; use add_tls_server_setup
function _setupTLSServerTest(serverBinName)
{
  let certdb = Cc["@mozilla.org/security/x509certdb;1"]
                  .getService(Ci.nsIX509CertDB);
  addCertFromFile(certdb, "tlsserver/test-ca.der", "CTu,u,u");
  const CALLBACK_PORT = 8444;
  let directoryService = Cc["@mozilla.org/file/directory_service;1"]
                           .getService(Ci.nsIProperties);
  let envSvc = Cc["@mozilla.org/process/environment;1"]
                 .getService(Ci.nsIEnvironment);
  let greDir = directoryService.get("GreD", Ci.nsIFile);
  envSvc.set("DYLD_LIBRARY_PATH", greDir.path);
  envSvc.set("LD_LIBRARY_PATH", greDir.path);
  envSvc.set("MOZ_TLS_SERVER_DEBUG_LEVEL", "3");
  envSvc.set("MOZ_TLS_SERVER_CALLBACK_PORT", CALLBACK_PORT);
  let httpServer = new HttpServer();
  httpServer.registerPathHandler("/",
      function handleServerCallback(aRequest, aResponse) {
        aResponse.setStatusLine(aRequest.httpVersion, 200, "OK");
        aResponse.setHeader("Content-Type", "text/plain");
        let responseBody = "OK!";
        aResponse.bodyOutputStream.write(responseBody, responseBody.length);
        do_execute_soon(function() {
          httpServer.stop(run_next_test);
        });
      });
  httpServer.start(CALLBACK_PORT);
  let serverBin = _getBinaryUtil(serverBinName);
  let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
  process.init(serverBin);
  let certDir = directoryService.get("CurWorkD", Ci.nsILocalFile);
  certDir.append("tlsserver");
  do_check_true(certDir.exists());
  process.run(false, [ "sql:" + certDir.path ], 1);
  do_register_cleanup(function() {
    process.kill();
  });
}
function _setupTLSServerTest ( serverBinName ) { let certdb = Cc [ "@mozilla.org/security/x509certdb;1" ] . getService ( Ci . nsIX509CertDB ) ; addCertFromFile ( certdb , "tlsserver/test-ca.der" , "CTu,u,u" ) ; const CALLBACK_PORT = 8444 ; let directoryService = Cc [ "@mozilla.org/file/directory_service;1" ] . getService ( Ci . nsIProperties ) ; let envSvc = Cc [ "@mozilla.org/process/environment;1" ] . getService ( Ci . nsIEnvironment ) ; let greDir = directoryService . get ( "GreD" , Ci . nsIFile ) ; envSvc . set ( "DYLD_LIBRARY_PATH" , greDir . path ) ; envSvc . set ( "LD_LIBRARY_PATH" , greDir . path ) ; envSvc . set ( "MOZ_TLS_SERVER_DEBUG_LEVEL" , "3" ) ; envSvc . set ( "MOZ_TLS_SERVER_CALLBACK_PORT" , CALLBACK_PORT ) ; let httpServer = new HttpServer ( ) ; httpServer . registerPathHandler ( "/" , function handleServerCallback ( aRequest , aResponse ) { aResponse . setStatusLine ( aRequest . httpVersion , 200 , "OK" ) ; aResponse . setHeader ( "Content-Type" , "text/plain" ) ; let responseBody = "OK!" ; aResponse . bodyOutputStream . write ( responseBody , responseBody . length ) ; do_execute_soon ( function ( ) { httpServer . stop ( run_next_test ) ; } ) ; } ) ; httpServer . start ( CALLBACK_PORT ) ; let serverBin = _getBinaryUtil ( serverBinName ) ; let process = Cc [ "@mozilla.org/process/util;1" ] . createInstance ( Ci . nsIProcess ) ; process . init ( serverBin ) ; let certDir = directoryService . get ( "CurWorkD" , Ci . nsILocalFile ) ; certDir . append ( "tlsserver" ) ; do_check_true ( certDir . exists ( ) ) ; process . run ( false , [ "sql:" + certDir . path ] , 1 ) ; do_register_cleanup ( function ( ) { process . kill ( ) ; } ) ; }
Do not call this directly; use add_tls_server_setup
Do not call this directly ; use add_tls_server_setup
// The trusted CA that is typically used for "good" certificates. // Using "sql:" causes the SQL DB to be used so we can run tests on Android.