[SOUP] Cleanups in SoupNetworkSession
authormcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Mar 2019 17:51:40 +0000 (17:51 +0000)
committermcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Mar 2019 17:51:40 +0000 (17:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195247

Reviewed by Daniel Bates.

This renames clientCertificates to allowedCertificates, since they are not client
certificates at all, but server certificates. It also adds a using statement to avoid
repeating the long type of the map, and avoids an unnecessary copy.

* platform/network/soup/SoupNetworkSession.cpp:
(WebCore::allowedCertificates):
(WebCore::SoupNetworkSession::checkTLSErrors):
(WebCore::SoupNetworkSession::allowSpecificHTTPSCertificateForHost):
(WebCore::clientCertificates): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242328 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/soup/SoupNetworkSession.cpp

index bcab12f..b7ea323 100644 (file)
@@ -1,5 +1,22 @@
 2019-03-03  Michael Catanzaro  <mcatanzaro@igalia.com>
 
+        [SOUP] Cleanups in SoupNetworkSession
+        https://bugs.webkit.org/show_bug.cgi?id=195247
+
+        Reviewed by Daniel Bates.
+
+        This renames clientCertificates to allowedCertificates, since they are not client
+        certificates at all, but server certificates. It also adds a using statement to avoid
+        repeating the long type of the map, and avoids an unnecessary copy.
+
+        * platform/network/soup/SoupNetworkSession.cpp:
+        (WebCore::allowedCertificates):
+        (WebCore::SoupNetworkSession::checkTLSErrors):
+        (WebCore::SoupNetworkSession::allowSpecificHTTPSCertificateForHost):
+        (WebCore::clientCertificates): Deleted.
+
+2019-03-03  Michael Catanzaro  <mcatanzaro@igalia.com>
+
         -Wformat error in SharedBuffer::tryCreateArrayBuffer
         https://bugs.webkit.org/show_bug.cgi?id=195004
 
index b967795..dcc8d51 100644 (file)
@@ -98,9 +98,11 @@ private:
     HashSet<String> m_certificates;
 };
 
-static HashMap<String, HostTLSCertificateSet, ASCIICaseInsensitiveHash>& clientCertificates()
+using AllowedCertificatesMap = HashMap<String, HostTLSCertificateSet, ASCIICaseInsensitiveHash>;
+
+static AllowedCertificatesMap& allowedCertificates()
 {
-    static NeverDestroyed<HashMap<String, HostTLSCertificateSet, ASCIICaseInsensitiveHash>> certificates;
+    static NeverDestroyed<AllowedCertificatesMap> certificates;
     return certificates;
 }
 
@@ -284,8 +286,8 @@ Optional<ResourceError> SoupNetworkSession::checkTLSErrors(const URL& requestURL
     if (!tlsErrors)
         return WTF::nullopt;
 
-    auto it = clientCertificates().find(requestURL.host().toString());
-    if (it != clientCertificates().end() && it->value.contains(certificate))
+    auto it = allowedCertificates().find(requestURL.host().toStringWithoutCopying());
+    if (it != allowedCertificates().end() && it->value.contains(certificate))
         return WTF::nullopt;
 
     return ResourceError::tlsError(requestURL, tlsErrors, certificate);
@@ -293,7 +295,7 @@ Optional<ResourceError> SoupNetworkSession::checkTLSErrors(const URL& requestURL
 
 void SoupNetworkSession::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)
 {
-    clientCertificates().add(host, HostTLSCertificateSet()).iterator->value.add(certificateInfo.certificate());
+    allowedCertificates().add(host, HostTLSCertificateSet()).iterator->value.add(certificateInfo.certificate());
 }
 
 } // namespace WebCore