Bug 208913

Summary: [Curl] Add an API returns description of verification errors.
Product: WebKit Reporter: Takashi Komori <takashi.komori>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, Basuke.Suzuki, chris.reid, darin, don.olmstead, ews-watchlist, galpeter, Hironori.Fujii, ross.kirsling, stephan.szabo, takashi.komori, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Takashi Komori 2020-03-11 05:33:41 PDT
Browser applications can get error code for verification by using WKCertificateInfoGetVerificationError but just displaying error code is inconvinient for users.
In this ticket we will add an API to provide error description and make MiniBrowser display error description  when it accesses sites which have invalid certs.
Comment 1 Takashi Komori 2020-03-11 06:02:52 PDT
Created attachment 393229 [details]
Patch
Comment 2 Takashi Komori 2020-03-11 06:05:34 PDT
(In reply to Takashi Komori from comment #1)
> Created attachment 393229 [details]
> Patch

Added test only tests the situation the error code is 0 (V509_V_OK).
This is because we can't set an arbitrary error code without connecting servers for now.

We will improve tests for this patch after establishing a method for testing bad certs in another ticket ( https://bugs.webkit.org/show_bug.cgi?id=208806 ).
Comment 3 Fujii Hironori 2020-03-17 12:34:00 PDT
Comment on attachment 393229 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=393229&action=review

> Tools/MiniBrowser/win/WebKitBrowserWindow.cpp:369
> +    auto certificateInfo = WKProtectionSpaceCopyCertificateInfo(protectionSpace);

Don't remove `adoptWK`. It will leak.

> Tools/MiniBrowser/win/WebKitBrowserWindow.cpp:371
> +    auto description = WKCertificateInfoCopyVerificationErrorDescription(certificateInfo);

Use adoptWK for the return value of *Copy* API. It will leak.

> Tools/TestWebKitAPI/Tests/WebKit/curl/Certificates.cpp:93
> +    ASSERT_TRUE(WKStringIsEqualToUTF8CString(WKCertificateInfoCopyVerificationErrorDescription(certificateInfo.get()), "ok"));

The return value of WKCertificateInfoCopyVerificationErrorDescription leaks.
Comment 4 Fujii Hironori 2020-03-17 12:34:51 PDT
You added a new WK2 API. Added WK2 owners in CC.
Comment 5 Takashi Komori 2020-03-19 04:31:04 PDT
Created attachment 393965 [details]
Patch
Comment 6 Takashi Komori 2020-03-19 04:37:17 PDT
(In reply to Fujii Hironori from comment #3)
> Comment on attachment 393229 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=393229&action=review
> 
> > Tools/MiniBrowser/win/WebKitBrowserWindow.cpp:369
> > +    auto certificateInfo = WKProtectionSpaceCopyCertificateInfo(protectionSpace);
> 
> Don't remove `adoptWK`. It will leak.

Fixed.

> 
> > Tools/MiniBrowser/win/WebKitBrowserWindow.cpp:371
> > +    auto description = WKCertificateInfoCopyVerificationErrorDescription(certificateInfo);
> 
> Use adoptWK for the return value of *Copy* API. It will leak.

Fixed.

> 
> > Tools/TestWebKitAPI/Tests/WebKit/curl/Certificates.cpp:93
> > +    ASSERT_TRUE(WKStringIsEqualToUTF8CString(WKCertificateInfoCopyVerificationErrorDescription(certificateInfo.get()), "ok"));
> 
> The return value of WKCertificateInfoCopyVerificationErrorDescription leaks.

Fixed.
Comment 7 youenn fablet 2020-03-19 07:42:37 PDT
New API looks ok to me
Comment 8 EWS 2020-03-19 14:19:01 PDT
Committed r258728: <https://trac.webkit.org/changeset/258728>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 393965 [details].
Comment 9 Radar WebKit Bug Importer 2020-03-19 14:20:14 PDT
<rdar://problem/60651795>