Skip to content

Commit

Permalink
Command line switch for the ultra security concious: --force-https!
Browse files Browse the repository at this point in the history
If you set this switch, the browser refuses to talk HTTP and refuses to permit certificate errors.  For best results, use with a dedicated profile.

R=jar

Review URL: http://codereview.chromium.org/14421

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6979 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
abarth@chromium.org committed Dec 15, 2008
1 parent 554c6ef commit 4ed2755
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions base/base_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ const wchar_t kProcessType[] = L"type";
// Enable DCHECKs in release mode.
const wchar_t kEnableDCHECK[] = L"enable-dcheck";

// Refuse to make HTTP connections and refuse to accept certificate errors.
const wchar_t kForceHTTPS[] = L"force-https";

} // namespace switches

1 change: 1 addition & 0 deletions base/base_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern const wchar_t kFullMemoryCrashReport[];
extern const wchar_t kNoErrorDialogs[];
extern const wchar_t kProcessType[];
extern const wchar_t kEnableDCHECK[];
extern const wchar_t kForceHTTPS[];

} // namespace switches

Expand Down
12 changes: 11 additions & 1 deletion net/url_request/url_request_http_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "net/url_request/url_request_http_job.h"

#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/file_version_info.h"
Expand Down Expand Up @@ -37,6 +39,13 @@ URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request,
return new URLRequestErrorJob(request, net::ERR_INVALID_ARGUMENT);
}

// We cache the value of the switch because this code path is hit on every
// network request.
static const bool kForceHTTPS =
CommandLine().HasSwitch(switches::kForceHTTPS);
if (kForceHTTPS && scheme != "https")
return new URLRequestErrorJob(request, net::ERR_DISALLOWED_URL_SCHEME);

return new URLRequestHttpJob(request);
}

Expand Down Expand Up @@ -375,7 +384,8 @@ void URLRequestHttpJob::OnStartCompleted(int result) {

if (result == net::OK) {
NotifyHeadersComplete();
} else if (net::IsCertificateError(result)) {
} else if (net::IsCertificateError(result) &&
!CommandLine().HasSwitch(switches::kForceHTTPS)) {
// We encountered an SSL certificate error. Ask our delegate to decide
// what we should do.
// TODO(wtc): also pass ssl_info.cert_status, or just pass the whole
Expand Down

0 comments on commit 4ed2755

Please sign in to comment.