From 146ef74dfecb43c8be2efec4a9a799e5ed6febd6 Mon Sep 17 00:00:00 2001
From: Freeman Lou <freeman@freeman-VirtualBox.(none)>
Date: Sun, 13 Jan 2013 16:23:56 -0500
Subject: [PATCH] user option for ssl authentication
---
.../network/curl/ResourceHandleManager.cpp | 10 ++++--
.../platform/network/curl/ResourceHandleManager.h | 9 +++++
Source/WebKit/haiku/API/WebWindow.cpp | 37 +++++++++++++++-----
Source/WebKit/haiku/API/WebWindow.h | 2 +-
.../WebCoreSupport/FrameLoaderClientHaiku.cpp | 3 +-
5 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp b/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp
index a1ace4b..7f54c0d 100644
a
|
b
|
ResourceHandleManager::ResourceHandleManager()
|
139 | 139 | , m_cookieJarFileName(0) |
140 | 140 | , m_certificatePath (certificatePath()) |
141 | 141 | , m_runningJobs(0) |
| 142 | , m_authenticateURL(true) |
142 | 143 | |
143 | 144 | { |
144 | 145 | curl_global_init(CURL_GLOBAL_ALL); |
… |
… |
void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job)
|
709 | 710 | |
710 | 711 | if (ret != 0) { |
711 | 712 | ResourceError error(String(handle->m_url), ret, String(handle->m_url), String(curl_easy_strerror(ret))); |
712 | | handle->client()->didFail(job, error); |
| 713 | handle->client()->didFail(job, error); |
713 | 714 | } |
714 | | |
| 715 | |
| 716 | m_authenticateURL = true; //reset |
715 | 717 | curl_easy_cleanup(handle->m_handle); |
716 | 718 | } |
717 | 719 | |
… |
… |
void ResourceHandleManager::initializeHandle(ResourceHandle* job)
|
861 | 863 | curl_easy_setopt(d->m_handle, CURLOPT_PROXY, m_proxy.utf8().data()); |
862 | 864 | curl_easy_setopt(d->m_handle, CURLOPT_PROXYTYPE, m_proxyType); |
863 | 865 | } |
| 866 | |
| 867 | if (m_authenticateURL == false && m_ignoredHost == url) |
| 868 | curl_easy_setopt(d->m_handle, CURLOPT_SSL_VERIFYPEER, false); |
| 869 | |
864 | 870 | } |
865 | 871 | |
866 | 872 | void ResourceHandleManager::cancel(ResourceHandle* job) |
diff --git a/Source/WebCore/platform/network/curl/ResourceHandleManager.h b/Source/WebCore/platform/network/curl/ResourceHandleManager.h
index ff54e73..d8363c3 100644
a
|
b
|
public:
|
68 | 68 | ProxyType type = HTTP, |
69 | 69 | const String& username = "", |
70 | 70 | const String& password = ""); |
| 71 | void setURLAuthentication(bool option) { |
| 72 | m_authenticateURL = option; |
| 73 | } |
| 74 | |
| 75 | void setIgnoredHost(String url) { |
| 76 | m_ignoredHost = url; |
| 77 | } |
71 | 78 | |
72 | 79 | private: |
73 | 80 | ResourceHandleManager(); |
… |
… |
private:
|
88 | 95 | Vector<ResourceHandle*> m_resourceHandleList; |
89 | 96 | const CString m_certificatePath; |
90 | 97 | int m_runningJobs; |
| 98 | static bool m_authenticateURL; |
91 | 99 | |
| 100 | String m_ignoredHost; |
92 | 101 | String m_proxy; |
93 | 102 | ProxyType m_proxyType; |
94 | 103 | }; |
diff --git a/Source/WebKit/haiku/API/WebWindow.cpp b/Source/WebKit/haiku/API/WebWindow.cpp
index eb4e95e..4dedd4c 100644
a
|
b
|
|
42 | 42 | #include <GridLayoutBuilder.h> |
43 | 43 | #include <GroupLayout.h> |
44 | 44 | #include <GroupLayoutBuilder.h> |
| 45 | #include <ResourceHandleManager.h> |
45 | 46 | #include <StringView.h> |
46 | 47 | #include <TextControl.h> |
47 | 48 | |
48 | 49 | #include <stdio.h> |
49 | 50 | |
| 51 | using namespace Webcore; |
| 52 | |
50 | 53 | enum { |
51 | 54 | ICON_FOR_URL_RECEIVED = 'icfu' |
52 | 55 | }; |
… |
… |
void BWebWindow::MessageReceived(BMessage* message)
|
172 | 175 | case MAIN_DOCUMENT_ERROR: { |
173 | 176 | BString failingURL; |
174 | 177 | BString localizedErrorString; |
| 178 | int32 errorNum; |
175 | 179 | if (message->FindString("url", &failingURL) == B_OK |
176 | | && message->FindString("error", &localizedErrorString) == B_OK) { |
177 | | MainDocumentError(failingURL, localizedErrorString, |
178 | | _WebViewForMessage(message)); |
| 180 | && message->FindString("error", &localizedErrorString) == B_OK |
| 181 | && message->FindInt32("errorCode", &errorCode) == B_OK) { |
| 182 | MainDocumentError(failingURL, localizedErrorString, |
| 183 | _WebViewForMessage(message), errorNum); |
179 | 184 | } |
180 | 185 | break; |
181 | 186 | } |
… |
… |
void BWebWindow::LoadFinished(const BString& url, BWebView* view)
|
371 | 376 | } |
372 | 377 | |
373 | 378 | void BWebWindow::MainDocumentError(const BString& failingURL, |
374 | | const BString& localizedDescription, BWebView* view) |
| 379 | const BString& localizedDescription, BWebView* view, int32 errorCode) |
375 | 380 | { |
376 | 381 | BString errorString("Error loading "); |
377 | 382 | errorString << failingURL; |
378 | 383 | errorString << ":\n\n"; |
379 | | errorString << localizedDescription; |
380 | | BAlert* alert = new BAlert("Main document error", errorString.String(), |
381 | | "OK"); |
382 | | alert->Go(NULL); |
| 384 | if (errorCode == CURLE_SSL_CACERT) { |
| 385 | errorString << curl_easy_strerror(CURL_SSL_CACERT); |
| 386 | BAlert* alert = new BAlert("Main document error", errorString.String(), |
| 387 | "Cancel", "Continue Anyway"); |
| 388 | } else { |
| 389 | errorString << localizedDescription; |
| 390 | BAlert* alert = new BAlert("Main document error", errorString.String(), |
| 391 | "OK"); |
| 392 | } |
| 393 | alert->SetShortCut(0, B_ESCAPE); |
| 394 | int32 option_index = alert->Go(); |
| 395 | if ( option_index == 1){ |
| 396 | KURL url; |
| 397 | url.setPath(failingURL); |
| 398 | ResourceHandleManager::setURLAuthentication(false); |
| 399 | ResourceHandleManager::setIgnoredHost(url.string()); |
| 400 | Webpage::Reload(errorString.String()); |
| 401 | |
| 402 | } else |
| 403 | return; |
383 | 404 | } |
384 | 405 | |
385 | 406 | void BWebWindow::TitleChanged(const BString& title, BWebView* view) |
diff --git a/Source/WebKit/haiku/API/WebWindow.h b/Source/WebKit/haiku/API/WebWindow.h
index e6d5a26..dafe565 100644
a
|
b
|
public:
|
71 | 71 | BWebView* view); |
72 | 72 | virtual void MainDocumentError(const BString& failingURL, |
73 | 73 | const BString& localizedDescription, |
74 | | BWebView* view); |
| 74 | BWebView* view, int32 errorCode); |
75 | 75 | virtual void TitleChanged(const BString& title, |
76 | 76 | BWebView* view); |
77 | 77 | virtual void IconReceived(const BBitmap* icon, |
diff --git a/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp b/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
index 550a579..a687393 100644
a
|
b
|
void FrameLoaderClientHaiku::setMainDocumentError(WebCore::DocumentLoader* loade
|
604 | 604 | BMessage message(MAIN_DOCUMENT_ERROR); |
605 | 605 | message.AddString("url", error.failingURL()); |
606 | 606 | message.AddString("error", error.localizedDescription()); |
607 | | dispatchMessage(message); |
| 607 | message.AddInt32("errorCode", error.errorCode()); |
| 608 | dispatchMessage(message); |
608 | 609 | } |
609 | 610 | |
610 | 611 | void FrameLoaderClientHaiku::postProgressStartedNotification() |