Bug 157220

Summary: On platforms that support it, use a SecTrustRef as the basis of CertificateInfo instead of a chain of SecCertificateRefs.
Product: WebKit Reporter: Sam Weinig <sam>
Component: New BugsAssignee: Sam Weinig <sam>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, benjamin, buildbot, cdumez, cmarcelo, commit-queue, darin, rniwa
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=159574
Attachments:
Description Flags
Patch
buildbot: commit-queue-
Archive of layout-test-results from ews105 for mac-yosemite-wk2
none
Patch 2 darin: review+

Description Sam Weinig 2016-04-29 18:00:24 PDT
On platforms that support it, use a SecTrustRef as the basis of CertificateInfo instead of a chain of SecCertificateRefs.
Comment 1 Sam Weinig 2016-04-29 18:20:39 PDT
Created attachment 277776 [details]
Patch
Comment 2 WebKit Commit Bot 2016-04-29 18:21:59 PDT
Attachment 277776 [details] did not pass style-queue:


ERROR: Source/WebKit2/Shared/Authentication/mac/AuthenticationManager.mac.mm:57:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 1 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Build Bot 2016-04-29 19:22:48 PDT
Comment on attachment 277776 [details]
Patch

Attachment 277776 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1242432

Number of test failures exceeded the failure limit.
Comment 4 Build Bot 2016-04-29 19:22:51 PDT
Created attachment 277782 [details]
Archive of layout-test-results from ews105 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 5 Sam Weinig 2016-04-29 21:17:54 PDT
Created attachment 277794 [details]
Patch 2
Comment 6 WebKit Commit Bot 2016-04-29 21:19:28 PDT
Attachment 277794 [details] did not pass style-queue:


ERROR: Source/WebKit2/Shared/Authentication/mac/AuthenticationManager.mac.mm:57:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 1 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Darin Adler 2016-04-29 22:28:36 PDT
Comment on attachment 277794 [details]
Patch 2

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

> Source/WebCore/platform/network/cf/CertificateInfo.h:39
> +    CertificateInfo()
> +    {
> +    }

Maybe "= default"? Would be nice to keep these function bodies out of the class definition so it’s easier to read.

> Source/WebCore/platform/network/cf/CertificateInfo.h:53
> +    explicit CertificateInfo(RetainPtr<SecTrustRef> trust)
> +        : m_trust(trust)
> +    {
> +    }

Just SecTrustRef for argument type? Or WTFMove to avoid retain churn? Maybe rvalue reference for argument type?

> Source/WebCore/platform/network/cf/CertificateInfo.h:61
>      CertificateInfo(RetainPtr<CFArrayRef> certificateChain)
>          : m_certificateChain(certificateChain)
> -    { }
> +    {
> +    }

Same questions.

> Source/WebCore/platform/network/cocoa/ResourceResponseCocoa.mm:109
> +    return CertificateInfo(adoptCF((CFArrayRef)certificateChain));

Why do we need the cast to CFArrayRef? Ambiguous or something?

> Source/WebCore/platform/network/mac/CertificateInfoMac.mm:55
> +        RetainPtr<NSMutableArray> array = adoptNS([[NSMutableArray alloc] init]);
> +        for (CFIndex i = 0, size = SecTrustGetCertificateCount(trust()); i < size; ++i)
> +            [array addObject:(id)SecTrustGetCertificateAtIndex(trust(), i)];
> +        m_certificateChain = (CFArrayRef)array.get();

This is  the same as the end of ResourceResponse::platformCertificateInfo. Can these share code?

> Source/WebCore/platform/network/mac/CertificateInfoMac.mm:59
> +    return m_certificateChain.get();

Kind of strange to fall into this in the HAVE(SEC_TRUST_SERIALIZATION) case. It’s just a less efficient way to return nullptr.

> Source/WebCore/platform/network/mac/CertificateInfoMac.mm:67
> +        for (CFIndex i = 0, size = SecTrustGetCertificateCount(trust()) - 1; i < size; ++i) {

What guarantees count is not zero?

> Source/WebCore/platform/network/mac/CertificateInfoMac.mm:68
> +            SecCertificateRef certificate = SecTrustGetCertificateAtIndex(trust(), i);

auto?

> Source/WebCore/platform/network/mac/CertificateInfoMac.mm:80
> +        for (CFIndex i = 0, size = CFArrayGetCount(m_certificateChain.get()) - 1; i < size; ++i) {

What guarantees the array count is not zero?

> Source/WebKit2/Shared/Authentication/mac/AuthenticationManager.mac.mm:56
> +    NSMutableArray *array = [NSMutableArray array];

arrayWithCapacity would be better
Comment 8 Darin Adler 2016-04-29 22:28:51 PDT
Looks like the Windows build failed.
Comment 9 Sam Weinig 2016-05-05 11:23:06 PDT
Committed r200463: <http://trac.webkit.org/changeset/200463>