WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Rebased to current git master
wk-ssl-errors5.diff (text/plain), 15.30 KB, created by
Carlos Garcia Campos
on 2012-07-13 03:14:50 PDT
(
hide
)
Description:
Rebased to current git master
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2012-07-13 03:14:50 PDT
Size:
15.30 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c894936..d05b8fc 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,49 @@ >+2012-07-13 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ Handle SSL errors for SOUP >+ https://bugs.webkit.org/show_bug.cgi?id=90267 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests, this is covered by existing tests. >+ >+ * platform/LocalizedStrings.h: >+ (WebCore): Add unacceptableTLSCertificate() for SOUP. >+ * platform/efl/LocalizedStringsEfl.cpp: >+ (WebCore::unacceptableTLSCertificate): >+ * platform/gtk/LocalizedStringsGtk.cpp: >+ (WebCore::unacceptableTLSCertificate): >+ * platform/network/ResourceHandle.h: >+ * platform/network/soup/ResourceError.h: >+ (WebCore::ResourceError::ResourceError): Add new constrcutor for >+ SSL errors that receives a certificate and TLS errors. >+ (WebCore::ResourceError::tlsErrors): Return TLS errors. >+ (WebCore::ResourceError::certificate): Return the certificate. >+ * platform/network/soup/ResourceHandleSoup.cpp: >+ (HostTLSCertificates): Helper class to store certificates for a >+ host. >+ (WebCore::HostTLSCertificates::add): Add a new certificate. >+ (WebCore::HostTLSCertificates::check): Check whether certificate >+ is stored. >+ (WebCore::HostTLSCertificates::computeCertificateHash): Compute >+ the SHA1 of the certificate data. >+ (WebCore::allowsAnyHTTPSCertificateHosts): Global set to store >+ hostnames for which SSL errors should be ignored. >+ (WebCore::clientCertificates): Global map to store client >+ certificates. >+ (WebCore::hasUnignoredTLSErrors): Helper function to check whether >+ current message contains TLS errors that shouldn't be ignored and >+ certificate hasn't been approved already. >+ (WebCore::sendRequestCallback): Finish the load with an error in >+ case of SSL errors not handled by the SoupSession. >+ (WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Add >+ the given hostname to the list of hosts for which SSL errors are >+ ignored. >+ (WebCore::ResourceHandle::setClientCertificate): Store the client >+ certificate for the given host. >+ (WebCore::ResourceHandle::setIgnoreSSLErrors): Set whether all SSL >+ errors should be ignored. >+ > 2012-07-12 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK] Add API to get HTTPS status to WebKit2 GTK+ >diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog >index 141f8bf..222dca1 100644 >--- a/Source/WebKit/efl/ChangeLog >+++ b/Source/WebKit/efl/ChangeLog >@@ -1,3 +1,15 @@ >+2012-07-13 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ Handle SSL errors for SOUP >+ https://bugs.webkit.org/show_bug.cgi?id=90267 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Ignore SSL errors by default for compatibility. >+ >+ * ewk/ewk_main.cpp: >+ (_ewk_init_body): >+ > 2012-07-10 Adam Barth <abarth@webkit.org> > > LayoutTestController.dumpConfigurationForViewport should move to Internals >diff --git a/Source/WebKit/gtk/ChangeLog b/Source/WebKit/gtk/ChangeLog >index 95fa53e..d326cb3 100644 >--- a/Source/WebKit/gtk/ChangeLog >+++ b/Source/WebKit/gtk/ChangeLog >@@ -1,3 +1,15 @@ >+2012-07-13 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ Handle SSL errors for SOUP >+ https://bugs.webkit.org/show_bug.cgi?id=90267 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Ignore SSL errors by default for compatibility. >+ >+ * webkit/webkitglobals.cpp: >+ (webkitInit): >+ > 2012-07-10 Adam Barth <abarth@webkit.org> > > WebCore::Settings for Hixie76 WebSocket protocol doesn't do anything and should be removed >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index c90085c..540b41f 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,17 @@ >+2012-07-13 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ Handle SSL errors for SOUP >+ https://bugs.webkit.org/show_bug.cgi?id=90267 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Ignore SSL errors by default for compatibility. >+ >+ * WebProcess/efl/WebProcessMainEfl.cpp: >+ (WebKit::WebProcessMainEfl): >+ * WebProcess/gtk/WebProcessMainGtk.cpp: >+ (WebKit::WebProcessMainGtk): >+ > 2012-07-12 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK] Add API to get HTTPS status to WebKit2 GTK+ >diff --git a/Source/WebCore/platform/LocalizedStrings.h b/Source/WebCore/platform/LocalizedStrings.h >index fe6686d..9133795 100644 >--- a/Source/WebCore/platform/LocalizedStrings.h >+++ b/Source/WebCore/platform/LocalizedStrings.h >@@ -219,6 +219,9 @@ namespace WebCore { > String dateFormatMonthText(); > String dateFormatDayInMonthText(); > #endif >+#if USE(SOUP) >+ String unacceptableTLSCertificate(); >+#endif > > #if !PLATFORM(CHROMIUM) > #define WEB_UI_STRING(string, description) WebCore::localizedString(string) >diff --git a/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp b/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp >index 263b5b3..9252fb1 100644 >--- a/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp >+++ b/Source/WebCore/platform/efl/LocalizedStringsEfl.cpp >@@ -566,6 +566,11 @@ String insecurePluginVersionText() > return String(); > } > >+String unacceptableTLSCertificate() >+{ >+ return String::fromUTF8("Unacceptable TLS certificate"); >+} >+ > String localizedString(const char* key) > { > return String::fromUTF8(key, strlen(key)); >diff --git a/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp b/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp >index 4bb2ce0..f6d2fbb 100644 >--- a/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp >+++ b/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp >@@ -717,6 +717,11 @@ String validationMessageStepMismatchText(const String&, const String&) > return String::fromUTF8(_("step mismatch")); > } > >+String unacceptableTLSCertificate() >+{ >+ return String::fromUTF8(_("Unacceptable TLS certificate")); >+} >+ > String localizedString(const char* key) > { > return String::fromUTF8(key, strlen(key)); >diff --git a/Source/WebCore/platform/network/ResourceHandle.h b/Source/WebCore/platform/network/ResourceHandle.h >index 5071f4b..cc2192f 100644 >--- a/Source/WebCore/platform/network/ResourceHandle.h >+++ b/Source/WebCore/platform/network/ResourceHandle.h >@@ -168,6 +168,9 @@ public: > > #if USE(SOUP) > static SoupSession* defaultSession(); >+ static void setHostAllowsAnyHTTPSCertificate(const String&); >+ static void setClientCertificate(const String& host, GTlsCertificate*); >+ static void setIgnoreSSLErrors(bool); > #endif > > // Used to work around the fact that you don't get any more NSURLConnection callbacks until you return from the one you're in. >diff --git a/Source/WebCore/platform/network/soup/ResourceError.h b/Source/WebCore/platform/network/soup/ResourceError.h >index 2d11367..37880e5 100644 >--- a/Source/WebCore/platform/network/soup/ResourceError.h >+++ b/Source/WebCore/platform/network/soup/ResourceError.h >@@ -27,6 +27,9 @@ > #define ResourceError_h > > #include "ResourceErrorBase.h" >+#include <wtf/gobject/GRefPtr.h> >+ >+typedef struct _GTlsCertificate GTlsCertificate; > > namespace WebCore { > >@@ -34,13 +37,29 @@ class ResourceError : public ResourceErrorBase > { > public: > ResourceError() >+ : m_tlsErrors(0) > { > } > > ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription) > : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription) >+ , m_tlsErrors(0) > { > } >+ >+ ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription, unsigned tlsErrors, GTlsCertificate* certificate) >+ : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription) >+ , m_tlsErrors(tlsErrors) >+ , m_certificate(certificate) >+ { >+ } >+ >+ unsigned tlsErrors() const { return m_tlsErrors; } >+ GTlsCertificate* certificate() const { return m_certificate.get(); } >+ >+private: >+ unsigned m_tlsErrors; >+ GRefPtr<GTlsCertificate> m_certificate; > }; > > } >diff --git a/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp b/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp >index 60e4e15..7aeb728 100644 >--- a/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp >+++ b/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp >@@ -35,6 +35,7 @@ > #include "Frame.h" > #include "GOwnPtrSoup.h" > #include "HTTPParsers.h" >+#include "LocalizedStrings.h" > #include "Logging.h" > #include "MIMETypeRegistry.h" > #include "NotImplemented.h" >@@ -56,6 +57,7 @@ > #include <sys/stat.h> > #include <sys/types.h> > #include <unistd.h> >+#include <wtf/SHA1.h> > #include <wtf/gobject/GRefPtr.h> > #include <wtf/text/CString.h> > >@@ -159,6 +161,43 @@ private: > GRefPtr<GMainLoop> m_mainLoop; > }; > >+class HostTLSCertificates { >+public: >+ static const size_t sha1HashSize = 20; >+ >+ void add(GTlsCertificate* certificate) >+ { >+ String certificateHash = computeCertificateHash(certificate); >+ if (!certificateHash.isEmpty()) >+ m_certificates.add(certificateHash); >+ } >+ >+ bool check(GTlsCertificate* certificate) >+ { >+ return m_certificates.contains(computeCertificateHash(certificate)); >+ } >+ >+private: >+ static String computeCertificateHash(GTlsCertificate* certificate) >+ { >+ GByteArray* data = 0; >+ g_object_get(G_OBJECT(certificate), "certificate", &data, NULL); >+ if (!data) >+ return String(); >+ >+ GRefPtr<GByteArray> certificateData = adoptGRef(data); >+ SHA1 sha1; >+ sha1.addBytes(certificateData->data, certificateData->len); >+ >+ Vector<uint8_t, sha1HashSize> digest; >+ sha1.computeHash(digest); >+ >+ return base64Encode(reinterpret_cast<const char*>(digest.data()), sha1HashSize); >+ } >+ >+ HashSet<String> m_certificates; >+}; >+ > static void cleanupSoupRequestOperation(ResourceHandle*, bool isDestroying); > static void sendRequestCallback(GObject*, GAsyncResult*, gpointer); > static void readCallback(GObject*, GAsyncResult*, gpointer); >@@ -168,6 +207,21 @@ static bool startNonHTTPRequest(ResourceHandle*, KURL); > static int milisecondsSinceRequest(double requestTime); > #endif > >+static bool gIgnoreSSLErrors = false; >+ >+static HashSet<String>& allowsAnyHTTPSCertificateHosts() >+{ >+ DEFINE_STATIC_LOCAL(HashSet<String>, hosts, ()); >+ return hosts; >+} >+ >+typedef HashMap<String, HostTLSCertificates> CertificatesMap; >+static CertificatesMap& clientCertificates() >+{ >+ DEFINE_STATIC_LOCAL(CertificatesMap, certificates, ()); >+ return certificates; >+} >+ > ResourceHandleInternal::~ResourceHandleInternal() > { > } >@@ -350,6 +404,13 @@ static ResourceError convertSoupErrorToResourceError(GError* error, SoupRequest* > String::fromUTF8(error->message)); > } > >+static inline bool hasUnignoredTLSErrors(ResourceHandle* handle) >+{ >+ return handle->getInternal()->m_response.soupMessageTLSErrors() >+ && !gIgnoreSSLErrors >+ && !allowsAnyHTTPSCertificateHosts().contains(handle->firstRequest().url().host().lower()); >+} >+ > static void sendRequestCallback(GObject* source, GAsyncResult* res, gpointer data) > { > RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data); >@@ -385,6 +446,18 @@ static void sendRequestCallback(GObject* source, GAsyncResult* res, gpointer dat > d->m_response.setSniffedContentType(sniffedType); > } > d->m_response.updateFromSoupMessage(soupMessage); >+ >+ if (hasUnignoredTLSErrors(handle.get())) { >+ CertificatesMap::iterator iter = clientCertificates().find(handle->firstRequest().url().host().lower()); >+ if (iter == clientCertificates().end() || !iter->second.check(d->m_response.soupMessageCertificate())) { >+ GOwnPtr<char> uri(soup_uri_to_string(soup_request_get_uri(d->m_soupRequest.get()), FALSE)); >+ client->didFail(handle.get(), ResourceError(g_quark_to_string(SOUP_HTTP_ERROR), SOUP_STATUS_SSL_FAILED, >+ uri.get(), unacceptableTLSCertificate(), >+ d->m_response.soupMessageTLSErrors(), d->m_response.soupMessageCertificate())); >+ cleanupSoupRequestOperation(handle.get()); >+ return; >+ } >+ } > } else { > d->m_response.setURL(handle->firstRequest().url()); > const gchar* contentType = soup_request_get_content_type(d->m_soupRequest.get()); >@@ -740,6 +813,21 @@ void ResourceHandle::cancel() > g_cancellable_cancel(d->m_cancellable.get()); > } > >+void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host) >+{ >+ allowsAnyHTTPSCertificateHosts().add(host.lower()); >+} >+ >+void ResourceHandle::setClientCertificate(const String& host, GTlsCertificate* certificate) >+{ >+ clientCertificates().add(host.lower(), HostTLSCertificates()).iterator->second.add(certificate); >+} >+ >+void ResourceHandle::setIgnoreSSLErrors(bool ignoreSSLErrors) >+{ >+ gIgnoreSSLErrors = ignoreSSLErrors; >+} >+ > static bool hasBeenSent(ResourceHandle* handle) > { > ResourceHandleInternal* d = handle->getInternal(); >diff --git a/Source/WebKit/efl/ewk/ewk_main.cpp b/Source/WebKit/efl/ewk/ewk_main.cpp >index b48c28a..a509067 100644 >--- a/Source/WebKit/efl/ewk/ewk_main.cpp >+++ b/Source/WebKit/efl/ewk/ewk_main.cpp >@@ -181,5 +181,7 @@ Eina_Bool _ewk_init_body(void) > SoupSessionFeature* auth_dialog = static_cast<SoupSessionFeature*>(g_object_new(EWK_TYPE_SOUP_AUTH_DIALOG, 0)); > soup_session_add_feature(session, auth_dialog); > >+ WebCore::ResourceHandle::setIgnoreSSLErrors(true); >+ > return true; > } >diff --git a/Source/WebKit/gtk/webkit/webkitglobals.cpp b/Source/WebKit/gtk/webkit/webkitglobals.cpp >index 42f7a1d..40356b8 100644 >--- a/Source/WebKit/gtk/webkit/webkitglobals.cpp >+++ b/Source/WebKit/gtk/webkit/webkitglobals.cpp >@@ -531,6 +531,8 @@ void webkitInit() > soup_session_add_feature(session, authDialog); > g_object_unref(authDialog); > >+ WebCore::ResourceHandle::setIgnoreSSLErrors(true); >+ > #if USE(CLUTTER) > gtk_clutter_init(0, 0); > #endif >diff --git a/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp b/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp >index 92d3516..6a0bbca 100644 >--- a/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp >+++ b/Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp >@@ -74,6 +74,8 @@ WK_EXPORT int WebProcessMainEfl(int argc, char* argv[]) > soup_uri_free(proxyUri); > } > >+ WebCore::ResourceHandle::setIgnoreSSLErrors(true); >+ > int socket = atoi(argv[1]); > WebProcess::shared().initialize(socket, RunLoop::main()); > RunLoop::run(); >diff --git a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp >index 45b8581..90f9fc5 100644 >--- a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp >+++ b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp >@@ -70,6 +70,9 @@ WK_EXPORT int WebProcessMainGtk(int argc, char* argv[]) > g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE, > SOUP_SESSION_SSL_STRICT, FALSE, NULL); > >+ // This is for compatibility, it will be removed when UI process can handle SSL errors. >+ WebCore::ResourceHandle::setIgnoreSSLErrors(true); >+ > RunLoop::run(); > > return 0;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mrobinson
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 90267
:
150136
|
151088
|
151657
|
151687
|
151712
| 152205