Ticket #6493: 0001-user-option-for-ssl-authentication.patch

File 0001-user-option-for-ssl-authentication.patch, 6.7 KB (added by Freeman, 11 years ago)

Basic fix for ssl error

  • Source/WebCore/platform/network/curl/ResourceHandleManager.cpp

    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()  
    139139    , m_cookieJarFileName(0)
    140140    , m_certificatePath (certificatePath())
    141141    , m_runningJobs(0)
     142    , m_authenticateURL(true)
    142143
    143144{
    144145    curl_global_init(CURL_GLOBAL_ALL);
    void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job)  
    709710
    710711    if (ret != 0) {
    711712        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);
    713714    }
    714 
     715   
     716    m_authenticateURL = true;  //reset
    715717    curl_easy_cleanup(handle->m_handle);
    716718}
    717719
    void ResourceHandleManager::initializeHandle(ResourceHandle* job)  
    861863        curl_easy_setopt(d->m_handle, CURLOPT_PROXY, m_proxy.utf8().data());
    862864        curl_easy_setopt(d->m_handle, CURLOPT_PROXYTYPE, m_proxyType);
    863865    }
     866   
     867    if (m_authenticateURL == false && m_ignoredHost == url)
     868        curl_easy_setopt(d->m_handle, CURLOPT_SSL_VERIFYPEER, false);
     869       
    864870}
    865871
    866872void ResourceHandleManager::cancel(ResourceHandle* job)
  • Source/WebCore/platform/network/curl/ResourceHandleManager.h

    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:  
    6868                      ProxyType type = HTTP,
    6969                      const String& username = "",
    7070                      const String& password = "");
     71    void setURLAuthentication(bool option) {
     72        m_authenticateURL = option;
     73    }
     74   
     75    void setIgnoredHost(String url) {
     76        m_ignoredHost = url;
     77    }
    7178
    7279private:
    7380    ResourceHandleManager();
    private:  
    8895    Vector<ResourceHandle*> m_resourceHandleList;
    8996    const CString m_certificatePath;
    9097    int m_runningJobs;
     98    static bool m_authenticateURL;
    9199   
     100    String m_ignoredHost;
    92101    String m_proxy;
    93102    ProxyType m_proxyType;
    94103};
  • Source/WebKit/haiku/API/WebWindow.cpp

    diff --git a/Source/WebKit/haiku/API/WebWindow.cpp b/Source/WebKit/haiku/API/WebWindow.cpp
    index eb4e95e..4dedd4c 100644
    a b  
    4242#include <GridLayoutBuilder.h>
    4343#include <GroupLayout.h>
    4444#include <GroupLayoutBuilder.h>
     45#include <ResourceHandleManager.h>
    4546#include <StringView.h>
    4647#include <TextControl.h>
    4748
    4849#include <stdio.h>
    4950
     51using namespace Webcore;
     52
    5053enum {
    5154    ICON_FOR_URL_RECEIVED = 'icfu'
    5255};
    void BWebWindow::MessageReceived(BMessage* message)  
    172175    case MAIN_DOCUMENT_ERROR: {
    173176        BString failingURL;
    174177        BString localizedErrorString;
     178        int32   errorNum;
    175179        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);
    179184        }
    180185        break;
    181186    }
    void BWebWindow::LoadFinished(const BString& url, BWebView* view)  
    371376}
    372377
    373378void BWebWindow::MainDocumentError(const BString& failingURL,
    374     const BString& localizedDescription, BWebView* view)
     379    const BString& localizedDescription, BWebView* view, int32 errorCode)
    375380{
    376381    BString errorString("Error loading ");
    377382    errorString << failingURL;
    378383    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;
    383404}
    384405
    385406void BWebWindow::TitleChanged(const BString& title, BWebView* view)
  • Source/WebKit/haiku/API/WebWindow.h

    diff --git a/Source/WebKit/haiku/API/WebWindow.h b/Source/WebKit/haiku/API/WebWindow.h
    index e6d5a26..dafe565 100644
    a b public:  
    7171                                    BWebView* view);
    7272    virtual void                MainDocumentError(const BString& failingURL,
    7373                                    const BString& localizedDescription,
    74                                     BWebView* view);
     74                                    BWebView* view, int32 errorCode);
    7575    virtual void                TitleChanged(const BString& title,
    7676                                    BWebView* view);
    7777    virtual void                IconReceived(const BBitmap* icon,
  • Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp

    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  
    604604    BMessage message(MAIN_DOCUMENT_ERROR);
    605605    message.AddString("url", error.failingURL());
    606606    message.AddString("error", error.localizedDescription());
    607     dispatchMessage(message);
     607    message.AddInt32("errorCode", error.errorCode());
     608     dispatchMessage(message);
    608609}
    609610
    610611void FrameLoaderClientHaiku::postProgressStartedNotification()