| Summary: | REGRESSION(255206@main): [curl] WKProtectionSpaceCopyCertificateInfo is defunct | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Fujii Hironori <Hironori.Fujii> | ||||||||||
| Component: | Page Loading | Assignee: | Fujii Hironori <Hironori.Fujii> | ||||||||||
| Status: | RESOLVED FIXED | ||||||||||||
| Severity: | Normal | CC: | achristensen, Basuke.Suzuki, beidson, cdumez, darin, don.olmstead, ross.kirsling, webkit-bug-importer | ||||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||||
| Version: | WebKit Nightly Build | ||||||||||||
| Hardware: | Unspecified | ||||||||||||
| OS: | Unspecified | ||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Fujii Hironori
2022-10-11 18:44:11 PDT
Since 255206@main (bug#245997) Created attachment 462932 [details]
Patch
Created attachment 462934 [details]
Patch
Created attachment 462935 [details]
Patch
Comment on attachment 462935 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=462935&action=review > COMMIT_MESSAGE:8 > +255206@main deprecated WKProtectionSpaceCopyCertificateInfo API and > +WKCertificateInfoRef. But, WinCairo and PlayStation ports are using > +it. Reverted the part of the change. Can we find a way to preserve deprecation warnings for uses of these on Apple ports? This is quite valuable to the Apple WebKit team. I suggest we create a variant of WK_C_API_DEPRECATED for cases like this where we want this on some ports but not others. Maybe a "Windows-only" version, or a "non-Apple-ports-only" version, depending on what people maintaining other ports want. Comment on attachment 462935 [details]
Patch
Rather than re-introduce the abstraction of WebCertificateInfo, let's add a function like this instead:
WKArrayRef WKProtectionSpaceCopyCertificateChain(WKProtectionSpaceRef protectionSpace);
Something like this. I haven't gotten it compiling and it has a small piece that still needs implementing, but I think this is a better design:
diff --git a/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.cpp b/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.cpp
index 03ae616a37c6..18e795cf5573 100644
--- a/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.cpp
+++ b/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.cpp
@@ -36,3 +36,22 @@ WKCertificateInfoRef WKProtectionSpaceCopyCertificateInfo(WKProtectionSpaceRef p
{
return nullptr;
}
+
+WKArrayRef WKProtectionSpaceCopyCertificateChain(WKProtectionSpaceRef protectionSpace)
+{
+ auto& certificateInfo = toImpl(protectionSpaceRef)->protectionSpace().certificateInfo();
+ (void)certificateInfo; // FIXME: Get the data of each certificate here.
+ return nullptr;
+}
+
+int WKProtectionSpaceGetCertificateVerificationError(WKProtectionSpaceRef protectionSpace)
+{
+ auto& certificateInfo = toImpl(protectionSpaceRef)->protectionSpace().certificateInfo();
+ return certificateInfo.verificationError();
+}
+
+WK_EXPORT WKStringRef WKProtectionSpaceCopyCertificateVerificationErrorDescription(WKProtectionSpaceRef protectionSpace)
+{
+ auto& certificateInfo = toImpl(protectionSpaceRef)->protectionSpace().certificateInfo();
+ return WebKit::toCopiedAPI(certificateInfo.verificationErrorDescription());
+}
diff --git a/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.h b/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.h
index 3161fc290cdf..c7d88217a738 100644
--- a/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.h
+++ b/Source/WebKit/UIProcess/API/C/curl/WKProtectionSpaceCurl.h
@@ -33,6 +33,9 @@ extern "C" {
#endif
WK_EXPORT WKCertificateInfoRef WKProtectionSpaceCopyCertificateInfo(WKProtectionSpaceRef) WK_C_API_DEPRECATED;
+WK_EXPORT WKArrayRef WKProtectionSpaceCopyCertificateChain(WKProtectionSpaceRef protectionSpace);
+WK_EXPORT int WKProtectionSpaceGetCertificateVerificationError(WKProtectionSpaceRef protectionSpace);
+WK_EXPORT WKStringRef WKProtectionSpaceCopyCertificateVerificationErrorDescription(WKProtectionSpaceRef protectionSpace);
#ifdef __cplusplus
}
diff --git a/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp b/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp
index 50565a2e540a..c312d116ec97 100644
--- a/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp
+++ b/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp
@@ -61,16 +61,16 @@ std::string createUTF8String(const wchar_t* src, size_t srcLength)
return { buffer.data(), actualLength };
}
-std::wstring createPEMString(WKCertificateInfoRef certificateInfo)
+std::wstring createPEMString(WKProtectionSpaceRef protectionSpace)
{
- auto chainSize = WKCertificateInfoGetCertificateChainSize(certificateInfo);
+ auto chain = adoptWK(WKProtectionSpaceCopyCertificateChain(protectionSpace));
std::wstring pems;
- for (auto i = 0; i < chainSize; i++) {
- auto certificate = adoptWK(WKCertificateInfoCopyCertificateAtIndex(certificateInfo, i));
- auto size = WKDataGetSize(certificate.get());
- auto data = WKDataGetBytes(certificate.get());
+ for (auto i = 0; i < WKArrayGetSize(chain.get()); i++) {
+ auto certificate = WKArrayGetItemAtIndex(chain.get(), i);
+ auto size = WKDataGetSize(certificate);
+ auto data = WKDataGetBytes(certificate);
for (size_t i = 0; i < size; i++)
pems.push_back(data[i]);
@@ -477,9 +477,9 @@ void WebKitBrowserWindow::didReceiveAuthenticationChallenge(WKPageRef page, WKAu
bool WebKitBrowserWindow::canTrustServerCertificate(WKProtectionSpaceRef protectionSpace)
{
auto host = createString(adoptWK(WKProtectionSpaceCopyHost(protectionSpace)).get());
- auto certificateInfo = adoptWK(WKProtectionSpaceCopyCertificateInfo(protectionSpace));
- auto verificationError = WKCertificateInfoGetVerificationError(certificateInfo.get());
- auto description = createString(adoptWK(WKCertificateInfoCopyVerificationErrorDescription(certificateInfo.get())).get());
+ auto verificationError = WKProtectionSpaceGetCertificateVerificationError(protectionSpace);
+ auto verificationError = WKProtectionSpaceCopyCertificateVerificationErrorDescription(protectionSpace);
+ auto description = createString(adoptWK(WKProtectionSpaceCopyCertificateVerificationErrorDescription(protectionSpace)).get());
auto pem = createPEMString(certificateInfo.get());
auto it = m_acceptedServerTrustCerts.find(host);
Created attachment 462947 [details]
Patch
Thanks! This is closer to the API shape of certificate chains on other platforms. Committed 255505@main (9fa349553d3f): <https://commits.webkit.org/255505@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 462947 [details]. |