Title: [282904] trunk/Source/WebCore
Revision
282904
Author
takashi.kom...@sony.com
Date
2021-09-22 20:28:06 -0700 (Wed, 22 Sep 2021)

Log Message

[Curl] Show TLS connection information in the inspector
https://bugs.webkit.org/show_bug.cgi?id=230526

Reviewed by Alex Christensen.

Add TLS version and cipher name in the network security tab.

No tests yet.

* platform/network/curl/CurlContext.cpp:
(WebCore::CurlHandle::addExtraNetworkLoadMetrics):
* platform/network/curl/CurlContext.h:
* platform/network/curl/OpenSSLHelper.cpp:
(OpenSSL::tlsVersion):
(OpenSSL::tlsCipherName):
* platform/network/curl/OpenSSLHelper.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282903 => 282904)


--- trunk/Source/WebCore/ChangeLog	2021-09-23 02:52:21 UTC (rev 282903)
+++ trunk/Source/WebCore/ChangeLog	2021-09-23 03:28:06 UTC (rev 282904)
@@ -1,3 +1,22 @@
+2021-09-22  Takashi Komori  <takashi.kom...@sony.com>
+
+        [Curl] Show TLS connection information in the inspector
+        https://bugs.webkit.org/show_bug.cgi?id=230526
+
+        Reviewed by Alex Christensen.
+
+        Add TLS version and cipher name in the network security tab.
+
+        No tests yet.
+
+        * platform/network/curl/CurlContext.cpp:
+        (WebCore::CurlHandle::addExtraNetworkLoadMetrics):
+        * platform/network/curl/CurlContext.h:
+        * platform/network/curl/OpenSSLHelper.cpp:
+        (OpenSSL::tlsVersion):
+        (OpenSSL::tlsCipherName):
+        * platform/network/curl/OpenSSLHelper.h:
+
 2021-09-22  Simon Fraser  <simon.fra...@apple.com>
 
         Move more scroll snap-related code into ScrollSnapAnimatorState

Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.cpp (282903 => 282904)


--- trunk/Source/WebCore/platform/network/curl/CurlContext.cpp	2021-09-23 02:52:21 UTC (rev 282903)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.cpp	2021-09-23 03:28:06 UTC (rev 282904)
@@ -865,6 +865,22 @@
     networkLoadMetrics.responseBodyBytesReceived = responseBodySize;
 
     auto additionalMetrics = AdditionalNetworkLoadMetricsForWebInspector::create();
+    if (!m_tlsConnectionInfo) {
+        curl_tlssessioninfo* info = nullptr;
+
+        errorCode = curl_easy_getinfo(m_handle, CURLINFO_TLS_SSL_PTR, &info);
+        if (errorCode != CURLE_OK)
+            return;
+
+        if (info && info->backend == CURLSSLBACKEND_OPENSSL && info->internals) {
+            auto ssl = static_cast<SSL*>(info->internals);
+
+            m_tlsConnectionInfo = makeUnique<TLSConnectionInfo>();
+            m_tlsConnectionInfo->protocol = OpenSSL::tlsVersion(ssl);
+            m_tlsConnectionInfo->cipher = OpenSSL::tlsCipherName(ssl);
+        }
+    }
+
     additionalMetrics->requestHeaderBytesSent = requestHeaderSize;
     additionalMetrics->requestBodyBytesSent = requestBodySize;
     additionalMetrics->responseHeaderBytesReceived = responseHeaderSize;
@@ -875,6 +891,11 @@
             additionalMetrics->remoteAddress.append(":" + String::number(port));
     }
 
+    if (m_tlsConnectionInfo) {
+        additionalMetrics->tlsProtocol = m_tlsConnectionInfo->protocol;
+        additionalMetrics->tlsCipher = m_tlsConnectionInfo->cipher;
+    }
+
     networkLoadMetrics.additionalNetworkLoadMetricsForWebInspector = WTFMove(additionalMetrics);
 }
 

Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.h (282903 => 282904)


--- trunk/Source/WebCore/platform/network/curl/CurlContext.h	2021-09-23 02:52:21 UTC (rev 282903)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.h	2021-09-23 03:28:06 UTC (rev 282904)
@@ -318,6 +318,12 @@
 #endif
 
 private:
+    struct TLSConnectionInfo {
+        WTF_MAKE_STRUCT_FAST_ALLOCATED;
+        String protocol;
+        String cipher;
+    };
+
     void enableRequestHeaders();
     static int expectedSizeOfCurlOffT();
 
@@ -329,7 +335,9 @@
 
     URL m_url;
     CurlSList m_requestHeaders;
+
     std::unique_ptr<CurlSSLVerifier> m_sslVerifier;
+    std::unique_ptr<TLSConnectionInfo> m_tlsConnectionInfo;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/curl/OpenSSLHelper.cpp (282903 => 282904)


--- trunk/Source/WebCore/platform/network/curl/OpenSSLHelper.cpp	2021-09-23 02:52:21 UTC (rev 282903)
+++ trunk/Source/WebCore/platform/network/curl/OpenSSLHelper.cpp	2021-09-23 03:28:06 UTC (rev 282904)
@@ -321,4 +321,14 @@
     return summaryInfo;
 }
 
+String tlsVersion(const SSL* ssl)
+{
+    return SSL_get_version(ssl);
 }
+
+String tlsCipherName(const SSL* ssl)
+{
+    return SSL_CIPHER_get_name(SSL_get_current_cipher(ssl));
+}
+
+}

Modified: trunk/Source/WebCore/platform/network/curl/OpenSSLHelper.h (282903 => 282904)


--- trunk/Source/WebCore/platform/network/curl/OpenSSLHelper.h	2021-09-23 02:52:21 UTC (rev 282903)
+++ trunk/Source/WebCore/platform/network/curl/OpenSSLHelper.h	2021-09-23 03:28:06 UTC (rev 282904)
@@ -34,4 +34,7 @@
 std::optional<WebCore::CertificateInfo> createCertificateInfo(X509_STORE_CTX*);
 std::optional<WebCore::CertificateSummary> createSummaryInfo(const Vector<uint8_t>& pem);
 
+String tlsVersion(const SSL*);
+String tlsCipherName(const SSL*);
+
 } // namespace OpenSSL
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to