12018-07-17 Basuke Suzuki <Basuke.Suzuki@sony.com>
2
3 [Curl] Disable CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST specified by setAllowsAnyHTTPSCertificate.
4 https://bugs.webkit.org/show_bug.cgi?id=187611
5
6 Reviewed by NOBODY (OOPS!).
7
8 Current interface for TLS certificate validation for Curl port are as follows:
9
10 - WEBCORE_EXPORT void setHostAllowsAnyHTTPSCertificate(const String&);
11 - bool isAllowedHTTPSCertificateHost(const String&);
12 - bool canIgnoredHTTPSCertificate(const String&, const Vector<CertificateInfo::Certificate>&);
13
14 First one registers a host to be ignored for any certificate check. Once it is registered, no
15 further certificate validation check is executed.
16 Second one checks the host is registered in the list above.
17 Third one is weird. The method signature implies it checks the certificate for the host and detect
18 whether we can ignore this certificate for the host, but actually it just check only the host and
19 register the certificate into the vector. Then in the next request for the host, the certificate
20 will be checked with the previously stored certificate.
21
22 It's hard to understand, but in short,
23 - We can register a host as an exception for any TLS certificate validation.
24 - But only certificate arrived first is ignored, not any certificates for the host
25 (which is rare, but possible for mis configured web cluster).
26
27 This behavior is incomplete. To ignore any certificates of the host, these two methods are enough:
28
29 - void allowAnyHTTPSCertificatesForHost(const String&)
30 - bool canIgnoreAnyHTTPSCertificatesForHost(const String&)
31
32 No new tests. Covered by existing tests.
33
34 * platform/network/curl/CertificateInfo.h:
35 * platform/network/curl/CurlContext.cpp:
36 (WebCore::CurlHandle::enableSSLForHost): Ignore TLS verification for registered host.
37 * platform/network/curl/CurlSSLHandle.cpp:
38 (WebCore::CurlSSLHandle::allowAnyHTTPSCertificatesForHost): Added.
39 (WebCore::CurlSSLHandle::canIgnoreAnyHTTPSCertificatesForHost const): Ditto.
40 (WebCore::CurlSSLHandle::setClientCertificateInfo): Separate lock.
41 (WebCore::CurlSSLHandle::getSSLClientCertificate const): Ditto and add const.
42 (WebCore::CurlSSLHandle::setHostAllowsAnyHTTPSCertificate): Deleted.
43 (WebCore::CurlSSLHandle::isAllowedHTTPSCertificateHost): Deleted.
44 (WebCore::CurlSSLHandle::canIgnoredHTTPSCertificate): Deleted.
45 (WebCore::CurlSSLHandle::getSSLClientCertificate): Deleted.
46 * platform/network/curl/CurlSSLHandle.h:
47 * platform/network/curl/CurlSSLVerifier.cpp:
48 (WebCore::CurlSSLVerifier::CurlSSLVerifier):
49 (WebCore::CurlSSLVerifier::collectInfo): Renamed from verify.
50 (WebCore::CurlSSLVerifier::verifyCallback):
51 (WebCore::CurlSSLVerifier::verify): Renamed to collectInfo.
52 * platform/network/curl/CurlSSLVerifier.h:
53 * platform/network/curl/ResourceHandleCurl.cpp:
54 (WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Rename calling method.
55