Bug 208913 - [Curl] Add an API returns description of verification errors.
Summary: [Curl] Add an API returns description of verification errors.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-11 05:33 PDT by Takashi Komori
Modified: 2020-03-19 14:20 PDT (History)
13 users (show)

See Also:


Attachments
Patch (11.60 KB, patch)
2020-03-11 06:02 PDT, Takashi Komori
no flags Details | Formatted Diff | Diff
Patch (11.87 KB, patch)
2020-03-19 04:31 PDT, Takashi Komori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>