WebKit Bugzilla
Attachment 339278 Details for
Bug 185138
: [Curl] Add OpenSSL/LibreSSL multi-threading support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
fix
185138.diff (text/plain), 4.02 KB, created by
Basuke Suzuki
on 2018-05-01 22:14:37 PDT
(
hide
)
Description:
fix
Filename:
MIME Type:
Creator:
Basuke Suzuki
Created:
2018-05-01 22:14:37 PDT
Size:
4.02 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 94ad2070a4e..c6cd4cbc424 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2018-04-30 Basuke Suzuki <Basuke.Suzuki@sony.com> >+ >+ [Curl] Add OpenSSL/LibreSSL multi-threading support >+ https://bugs.webkit.org/show_bug.cgi?id=185138 >+ >+ The older OpenSSL manual says the locking_function and threadid_funcion should >+ set when use it in multi-threading environment. This applies to LibreSSL also. >+ https://www.openssl.org/docs/man1.0.2/crypto/threads.html >+ >+ For unix and other similar os, the default threadId_function implementation is >+ good enough. We'll set custom callback only for Windows OS. >+ >+ Note it's not required for OpenSSL 1.1.0 and after. >+ https://www.openssl.org/blog/blog/2017/02/21/threads/ >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * platform/network/curl/CurlSSLHandle.cpp: >+ (WebCore::CurlSSLHandle::CurlSSLHandle): >+ (WebCore::CurlSSLHandle::setupThreadSettings): >+ (WebCore::CurlSSLHandle::lockingCallback): >+ (WebCore::CurlSSLHandle::threadIdCallback): >+ * platform/network/curl/CurlSSLHandle.h: >+ > 2018-04-30 Michael Catanzaro <mcatanzaro@igalia.com> > > [GTK] Webkit should spoof as Safari on a Mac when on Chase.com >diff --git a/Source/WebCore/platform/network/curl/CurlSSLHandle.cpp b/Source/WebCore/platform/network/curl/CurlSSLHandle.cpp >index 3c7fd20548d..12417547702 100644 >--- a/Source/WebCore/platform/network/curl/CurlSSLHandle.cpp >+++ b/Source/WebCore/platform/network/curl/CurlSSLHandle.cpp >@@ -37,6 +37,10 @@ > #include <wtf/RetainPtr.h> > #endif > >+#if NEED_OPENSSL_THREAD_ID_CALLBACK && OS(WINDOWS) >+#include <wtf/Threading.h> >+#endif >+ > namespace WebCore { > > CurlSSLHandle::CurlSSLHandle() >@@ -45,6 +49,10 @@ CurlSSLHandle::CurlSSLHandle() > char* ignoreSSLErrors = getenv("WEBKIT_IGNORE_SSL_ERRORS"); > if (ignoreSSLErrors) > m_ignoreSSLErrors = true; >+ >+#if NEED_OPENSSL_THREAD_ID_CALLBACK >+ setupThreadSettings(); >+#endif > } > > CString CurlSSLHandle::getCACertPathEnv() >@@ -120,6 +128,38 @@ std::optional<CurlSSLHandle::ClientCertificate> CurlSSLHandle::getSSLClientCerti > return it->value; > } > >+#if NEED_OPENSSL_THREAD_ID_CALLBACK >+ >+void CurlSSLHandle::setupThreadSettings() >+{ >+ CRYPTO_set_locking_callback(lockingCallback); >+#if OS(WINDOWS) >+ CRYPTO_THREADID_set_callback(threadIdCallback); >+#endif >+} >+ >+void CurlSSLHandle::lockingCallback(int mode, int type, const char*, int) >+{ >+ static Lock lock[CRYPTO_NUM_LOCKS]; >+ ASSERT(type >= 0 && type < CRYPTO_NUM_LOCKS); >+ >+ if (mode & CRYPTO_LOCK) >+ lock[type].lock(); >+ else >+ lock[type].unlock(); >+} >+ >+#if OS(WINDOWS) >+ >+void CurlSSLHandle::threadIdCallback(CRYPTO_THREADID* threadId) >+{ >+ CRYPTO_THREADID_set_numeric(threadId, static_cast<unsigned long>(Thread::currentID())); >+} >+ >+#endif >+ >+#endif >+ > } > > #endif >diff --git a/Source/WebCore/platform/network/curl/CurlSSLHandle.h b/Source/WebCore/platform/network/curl/CurlSSLHandle.h >index 088e64a6f34..5a3a70206f2 100644 >--- a/Source/WebCore/platform/network/curl/CurlSSLHandle.h >+++ b/Source/WebCore/platform/network/curl/CurlSSLHandle.h >@@ -31,12 +31,18 @@ > #include <wtf/Noncopyable.h> > #include <wtf/text/StringHash.h> > >+#if (!defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x1010000fL) >+#define NEED_OPENSSL_THREAD_ID_CALLBACK 0 >+#else >+#define NEED_OPENSSL_THREAD_ID_CALLBACK 1 >+#include <openssl/crypto.h> >+#endif >+ > namespace WebCore { > > class CurlSSLHandle { > WTF_MAKE_NONCOPYABLE(CurlSSLHandle); > friend NeverDestroyed<CurlSSLHandle>; >- > public: > CurlSSLHandle(); > >@@ -55,6 +61,14 @@ public: > private: > CString getCACertPathEnv(); > >+#if NEED_OPENSSL_THREAD_ID_CALLBACK >+ void setupThreadSettings(); >+ static void lockingCallback(int mode, int type, const char* file, int line); >+#if OS(WINDOWS) >+ static void threadIdCallback(CRYPTO_THREADID*); >+#endif >+#endif >+ > bool m_ignoreSSLErrors { false }; > CString m_caCertPath; >
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185138
:
339130
|
339278
|
339279
|
339340
|
339353
|
339391
|
339392