summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ssl
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 18:50:18 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 18:50:18 +0000
commit8959d8342fef3cb28304ab0958982314a64f6642 (patch)
tree6d3ba544d5412c8deaf495b22f3200a1604bdfa0 /chrome/browser/ssl
parent8ca2f4aa621c51c7abdbb2af97acfd5133d8b79d (diff)
downloadchromium_src-8959d8342fef3cb28304ab0958982314a64f6642.zip
chromium_src-8959d8342fef3cb28304ab0958982314a64f6642.tar.gz
chromium_src-8959d8342fef3cb28304ab0958982314a64f6642.tar.bz2
Reverting 16164.
Review URL: http://codereview.chromium.org/113471 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16165 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ssl')
-rw-r--r--chrome/browser/ssl/ssl_host_state_unittest.cc174
-rw-r--r--chrome/browser/ssl/ssl_policy_backend.cc14
-rw-r--r--chrome/browser/ssl/ssl_policy_backend.h44
3 files changed, 39 insertions, 193 deletions
diff --git a/chrome/browser/ssl/ssl_host_state_unittest.cc b/chrome/browser/ssl/ssl_host_state_unittest.cc
deleted file mode 100644
index f88b45d..0000000
--- a/chrome/browser/ssl/ssl_host_state_unittest.cc
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ssl/ssl_host_state.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-// Certificates for test data. They're obtained with:
-//
-// $ openssl s_client -connect [host]:443 -showcerts
-// $ openssl x509 -inform PEM -outform DER > /tmp/host.der
-// $ xxd -i /tmp/host.der
-
-// Google's cert.
-
-unsigned char google_der[] = {
- 0x30, 0x82, 0x03, 0x21, 0x30, 0x82, 0x02, 0x8a, 0xa0, 0x03, 0x02, 0x01,
- 0x02, 0x02, 0x10, 0x3c, 0x8d, 0x3a, 0x64, 0xee, 0x18, 0xdd, 0x1b, 0x73,
- 0x0b, 0xa1, 0x92, 0xee, 0xf8, 0x98, 0x1b, 0x30, 0x0d, 0x06, 0x09, 0x2a,
- 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x4c,
- 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x5a,
- 0x41, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x1c,
- 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x75,
- 0x6c, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x28, 0x50, 0x74, 0x79, 0x29, 0x20,
- 0x4c, 0x74, 0x64, 0x2e, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04,
- 0x03, 0x13, 0x0d, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x53, 0x47,
- 0x43, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x38, 0x30, 0x35,
- 0x30, 0x32, 0x31, 0x37, 0x30, 0x32, 0x35, 0x35, 0x5a, 0x17, 0x0d, 0x30,
- 0x39, 0x30, 0x35, 0x30, 0x32, 0x31, 0x37, 0x30, 0x32, 0x35, 0x35, 0x5a,
- 0x30, 0x68, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
- 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08,
- 0x13, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61,
- 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13, 0x0d, 0x4d,
- 0x6f, 0x75, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77,
- 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0a, 0x47,
- 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x17, 0x30,
- 0x15, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0e, 0x77, 0x77, 0x77, 0x2e,
- 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x81,
- 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
- 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02,
- 0x81, 0x81, 0x00, 0x9b, 0x19, 0xed, 0x5d, 0xa5, 0x56, 0xaf, 0x49, 0x66,
- 0xdb, 0x79, 0xfd, 0xc2, 0x1c, 0x78, 0x4e, 0x4f, 0x11, 0xa5, 0x8a, 0xac,
- 0xe2, 0x94, 0xee, 0xe3, 0xe2, 0x4b, 0xc0, 0x03, 0x25, 0xa7, 0x99, 0xcc,
- 0x65, 0xe1, 0xec, 0x94, 0xae, 0xae, 0xf0, 0xa7, 0x99, 0xbc, 0x10, 0xd7,
- 0xed, 0x87, 0x30, 0x47, 0xcd, 0x50, 0xf9, 0xaf, 0xd3, 0xd3, 0xf4, 0x0b,
- 0x8d, 0x47, 0x8a, 0x2e, 0xe2, 0xce, 0x53, 0x9b, 0x91, 0x99, 0x7f, 0x1e,
- 0x5c, 0xf9, 0x1b, 0xd6, 0xe9, 0x93, 0x67, 0xe3, 0x4a, 0xf8, 0xcf, 0xc4,
- 0x8c, 0x0c, 0x68, 0xd1, 0x97, 0x54, 0x47, 0x0e, 0x0a, 0x24, 0x30, 0xa7,
- 0x82, 0x94, 0xae, 0xde, 0xae, 0x3f, 0xbf, 0xba, 0x14, 0xc6, 0xf8, 0xb2,
- 0x90, 0x8e, 0x36, 0xad, 0xe1, 0xd0, 0xbe, 0x16, 0x9a, 0xb3, 0x5e, 0x72,
- 0x38, 0x49, 0xda, 0x74, 0xa1, 0x3f, 0xff, 0xd2, 0x87, 0x81, 0xed, 0x02,
- 0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, 0xe7, 0x30, 0x81, 0xe4, 0x30, 0x28,
- 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x21, 0x30, 0x1f, 0x06, 0x08, 0x2b,
- 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06, 0x01,
- 0x05, 0x05, 0x07, 0x03, 0x02, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86,
- 0xf8, 0x42, 0x04, 0x01, 0x30, 0x36, 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04,
- 0x2f, 0x30, 0x2d, 0x30, 0x2b, 0xa0, 0x29, 0xa0, 0x27, 0x86, 0x25, 0x68,
- 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x72, 0x6c, 0x2e, 0x74, 0x68,
- 0x61, 0x77, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x68, 0x61,
- 0x77, 0x74, 0x65, 0x53, 0x47, 0x43, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x6c,
- 0x30, 0x72, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x01,
- 0x04, 0x66, 0x30, 0x64, 0x30, 0x22, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
- 0x05, 0x07, 0x30, 0x01, 0x86, 0x16, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
- 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x74, 0x68, 0x61, 0x77, 0x74, 0x65,
- 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x3e, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
- 0x05, 0x07, 0x30, 0x02, 0x86, 0x32, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
- 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x74, 0x68, 0x61, 0x77, 0x74, 0x65, 0x2e,
- 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f,
- 0x72, 0x79, 0x2f, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x5f, 0x53, 0x47,
- 0x43, 0x5f, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x74, 0x30, 0x0c, 0x06, 0x03,
- 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0d,
- 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05,
- 0x00, 0x03, 0x81, 0x81, 0x00, 0x31, 0x0a, 0x6c, 0xa2, 0x9e, 0xe9, 0x54,
- 0x19, 0x16, 0x68, 0x99, 0x91, 0xd6, 0x43, 0xcb, 0x6b, 0xb4, 0xcc, 0x6c,
- 0xcc, 0xb0, 0xfb, 0xf1, 0xee, 0x81, 0xbf, 0x00, 0x2b, 0x6f, 0x50, 0x12,
- 0xc6, 0xaf, 0x02, 0x2a, 0x36, 0xc1, 0x28, 0xde, 0xc5, 0x4c, 0x56, 0x20,
- 0x6d, 0xf5, 0x3d, 0x42, 0xb9, 0x18, 0x81, 0x20, 0xb2, 0xdd, 0x57, 0x5d,
- 0xeb, 0xbe, 0x32, 0x84, 0x50, 0x45, 0x51, 0x6e, 0xcd, 0xe4, 0x2e, 0x2a,
- 0x38, 0x88, 0x9f, 0x52, 0xed, 0x28, 0xff, 0xfc, 0x8d, 0x57, 0xb5, 0xad,
- 0x64, 0xae, 0x4d, 0x0e, 0x0e, 0xd9, 0x3d, 0xac, 0xb8, 0xfe, 0x66, 0x4c,
- 0x15, 0x8f, 0x44, 0x52, 0xfa, 0x7c, 0x3c, 0x04, 0xed, 0x7f, 0x37, 0x61,
- 0x04, 0xfe, 0xd5, 0xe9, 0xb9, 0xb0, 0x9e, 0xfe, 0xa5, 0x11, 0x69, 0xc9,
- 0x63, 0xd6, 0x46, 0x81, 0x6f, 0x00, 0xd8, 0x72, 0x2f, 0x82, 0x37, 0x44,
- 0xc1
-};
-
-} // namespace
-
-class SSLHostStateTest : public testing::Test {
-};
-
-TEST_F(SSLHostStateTest, MarkHostAsBroken) {
- SSLHostState state;
-
- EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 42));
- EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 191));
- EXPECT_FALSE(state.DidMarkHostAsBroken("example.com", 42));
-
- state.MarkHostAsBroken("www.google.com", 42);
-
- EXPECT_TRUE(state.DidMarkHostAsBroken("www.google.com", 42));
- EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 191));
- EXPECT_FALSE(state.DidMarkHostAsBroken("example.com", 42));
-
- state.MarkHostAsBroken("example.com", 42);
-
- EXPECT_TRUE(state.DidMarkHostAsBroken("www.google.com", 42));
- EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 191));
- EXPECT_TRUE(state.DidMarkHostAsBroken("example.com", 42));
-}
-
-TEST_F(SSLHostStateTest, QueryPolicy) {
- scoped_refptr<net::X509Certificate> google_cert =
- net::X509Certificate::CreateFromBytes(
- reinterpret_cast<const char*>(google_der), sizeof(google_der));
-
- SSLHostState state;
-
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"),
- net::X509Certificate::Policy::UNKNOWN);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"),
- net::X509Certificate::Policy::UNKNOWN);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"),
- net::X509Certificate::Policy::UNKNOWN);
-
- state.AllowCertForHost(google_cert.get(), "www.google.com");
-
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"),
- net::X509Certificate::Policy::ALLOWED);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"),
- net::X509Certificate::Policy::UNKNOWN);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"),
- net::X509Certificate::Policy::UNKNOWN);
-
- state.AllowCertForHost(google_cert.get(), "example.com");
-
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"),
- net::X509Certificate::Policy::ALLOWED);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"),
- net::X509Certificate::Policy::UNKNOWN);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"),
- net::X509Certificate::Policy::ALLOWED);
-
- state.DenyCertForHost(google_cert.get(), "example.com");
-
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"),
- net::X509Certificate::Policy::ALLOWED);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"),
- net::X509Certificate::Policy::UNKNOWN);
- EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"),
- net::X509Certificate::Policy::DENIED);
-}
-
-TEST_F(SSLHostStateTest, AllowMixedContentForHost) {
- SSLHostState state;
-
- EXPECT_FALSE(state.DidAllowMixedContentForHost("www.google.com"));
- EXPECT_FALSE(state.DidAllowMixedContentForHost("google.com"));
- EXPECT_FALSE(state.DidAllowMixedContentForHost("example.com"));
-
- state.AllowMixedContentForHost("www.google.com");
-
- EXPECT_TRUE(state.DidAllowMixedContentForHost("www.google.com"));
- EXPECT_FALSE(state.DidAllowMixedContentForHost("google.com"));
- EXPECT_FALSE(state.DidAllowMixedContentForHost("example.com"));
-
- state.AllowMixedContentForHost("example.com");
-
- EXPECT_TRUE(state.DidAllowMixedContentForHost("www.google.com"));
- EXPECT_FALSE(state.DidAllowMixedContentForHost("google.com"));
- EXPECT_TRUE(state.DidAllowMixedContentForHost("example.com"));
-}
diff --git a/chrome/browser/ssl/ssl_policy_backend.cc b/chrome/browser/ssl/ssl_policy_backend.cc
index 49f98ea..9b1eed8 100644
--- a/chrome/browser/ssl/ssl_policy_backend.cc
+++ b/chrome/browser/ssl/ssl_policy_backend.cc
@@ -104,6 +104,20 @@ void SSLPolicyBackend::ShowMessageWithLink(const std::wstring& msg,
}
}
+bool SSLPolicyBackend::SetMaxSecurityStyle(SecurityStyle style) {
+ NavigationEntry* entry = controller_->GetActiveEntry();
+ if (!entry) {
+ NOTREACHED();
+ return false;
+ }
+
+ if (entry->ssl().security_style() > style) {
+ entry->ssl().set_security_style(style);
+ return true;
+ }
+ return false;
+}
+
void SSLPolicyBackend::AddMessageToConsole(
const string16& message, const WebConsoleMessage::Level& level) {
controller_->tab_contents()->render_view_host()->AddMessageToConsole(
diff --git a/chrome/browser/ssl/ssl_policy_backend.h b/chrome/browser/ssl/ssl_policy_backend.h
index 5b59a7c..f8a829c 100644
--- a/chrome/browser/ssl/ssl_policy_backend.h
+++ b/chrome/browser/ssl/ssl_policy_backend.h
@@ -20,56 +20,62 @@ class Task;
class SSLPolicyBackend {
public:
explicit SSLPolicyBackend(NavigationController* controller);
- virtual ~SSLPolicyBackend();
// Ensure that the specified message is displayed to the user. This will
// display an InfoBar at the top of the associated tab.
- virtual void ShowMessage(const std::wstring& msg);
+ void ShowMessage(const std::wstring& msg);
// Same as ShowMessage but also contains a link that when clicked run the
// specified task. The SSL Manager becomes the owner of the task.
- virtual void ShowMessageWithLink(const std::wstring& msg,
- const std::wstring& link_text,
- Task* task);
+ void ShowMessageWithLink(const std::wstring& msg,
+ const std::wstring& link_text,
+ Task* task);
// Records that a host is "broken," that is, the origin for that host has been
// contaminated with insecure content, either via HTTP or via HTTPS with a
// bad certificate.
- virtual void MarkHostAsBroken(const std::string& host, int pid);
+ void MarkHostAsBroken(const std::string& host, int pid);
// Returns whether the specified host was marked as broken.
- virtual bool DidMarkHostAsBroken(const std::string& host, int pid) const;
+ bool DidMarkHostAsBroken(const std::string& host, int pid) const;
+
+ // Sets the maximum security style for the page. If the current security
+ // style is lower than |style|, this will not have an effect on the security
+ // indicators.
+ //
+ // It will return true if the navigation entry was updated or false if
+ // nothing changed. The caller is responsible for broadcasting
+ // NOTIFY_SSY_STATE_CHANGED if it returns true.
+ bool SetMaxSecurityStyle(SecurityStyle style);
// Logs a message to the console of the page.
- virtual void AddMessageToConsole(const string16& message,
- const WebKit::WebConsoleMessage::Level&);
+ void AddMessageToConsole(const string16& message,
+ const WebKit::WebConsoleMessage::Level&);
// Records that |cert| is permitted to be used for |host| in the future.
- virtual void DenyCertForHost(net::X509Certificate* cert,
- const std::string& host);
+ void DenyCertForHost(net::X509Certificate* cert, const std::string& host);
// Records that |cert| is not permitted to be used for |host| in the future.
- virtual void AllowCertForHost(net::X509Certificate* cert,
- const std::string& host);
+ void AllowCertForHost(net::X509Certificate* cert, const std::string& host);
// Queries whether |cert| is allowed or denied for |host|.
- virtual net::X509Certificate::Policy::Judgment QueryPolicy(
+ net::X509Certificate::Policy::Judgment QueryPolicy(
net::X509Certificate* cert, const std::string& host);
// Allow mixed content to be visible (non filtered).
- virtual void AllowMixedContentForHost(const std::string& host);
+ void AllowMixedContentForHost(const std::string& host);
// Returns whether the specified host is allowed to show mixed content.
- virtual bool DidAllowMixedContentForHost(const std::string& host) const;
+ bool DidAllowMixedContentForHost(const std::string& host) const;
// Reloads the tab.
- virtual void Reload();
+ void Reload();
// Shows the pending messages (in info-bars) if any.
- virtual void ShowPendingMessages();
+ void ShowPendingMessages();
// Clears any pending messages.
- virtual void ClearPendingMessages();
+ void ClearPendingMessages();
private:
// SSLMessageInfo contains the information necessary for displaying a message