Title: [203040] trunk/Source
Revision
203040
Author
[email protected]
Date
2016-07-10 11:48:50 -0700 (Sun, 10 Jul 2016)

Log Message

Fix client certificate authentication after r200463
https://bugs.webkit.org/show_bug.cgi?id=159574
<rdar://problem/26931006>

Patch by Alex Christensen <[email protected]> on 2016-07-10
Reviewed by Sam Weinig.

Source/WebCore:

No new tests.  We really need a test for this

* platform/network/cf/CertificateInfo.h:
(WebCore::CertificateInfo::CertificateInfo):
(WebCore::CertificateInfo::trust):
Make sure we only get the trust for Trust type CertificateInfos.
If we mix up our types, we get unexpected nullptrs, which will cause authentication to fail.

Source/WebKit2:

* Shared/Authentication/mac/AuthenticationManager.mac.mm:
(WebKit::leafCertificate):
(WebKit::chain):
Handle the different types of CertificateInfos.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203039 => 203040)


--- trunk/Source/WebCore/ChangeLog	2016-07-10 17:53:50 UTC (rev 203039)
+++ trunk/Source/WebCore/ChangeLog	2016-07-10 18:48:50 UTC (rev 203040)
@@ -1,3 +1,19 @@
+2016-07-10  Alex Christensen  <[email protected]>
+
+        Fix client certificate authentication after r200463
+        https://bugs.webkit.org/show_bug.cgi?id=159574
+        <rdar://problem/26931006>
+
+        Reviewed by Sam Weinig.
+
+        No new tests.  We really need a test for this
+
+        * platform/network/cf/CertificateInfo.h:
+        (WebCore::CertificateInfo::CertificateInfo):
+        (WebCore::CertificateInfo::trust):
+        Make sure we only get the trust for Trust type CertificateInfos.  
+        If we mix up our types, we get unexpected nullptrs, which will cause authentication to fail.
+
 2016-07-10  Myles C. Maxfield  <[email protected]>
 
         Fix Windows build after r203038

Modified: trunk/Source/WebCore/platform/network/cf/CertificateInfo.h (203039 => 203040)


--- trunk/Source/WebCore/platform/network/cf/CertificateInfo.h	2016-07-10 17:53:50 UTC (rev 203039)
+++ trunk/Source/WebCore/platform/network/cf/CertificateInfo.h	2016-07-10 18:48:50 UTC (rev 203040)
@@ -53,7 +53,7 @@
     {
     }
  
-    SecTrustRef trust() const { return m_trust.get(); }
+    SecTrustRef trust() const { ASSERT(m_trust); return m_trust.get(); }
 #endif
 
     CertificateInfo(RetainPtr<CFArrayRef>&& certificateChain)

Modified: trunk/Source/WebKit2/ChangeLog (203039 => 203040)


--- trunk/Source/WebKit2/ChangeLog	2016-07-10 17:53:50 UTC (rev 203039)
+++ trunk/Source/WebKit2/ChangeLog	2016-07-10 18:48:50 UTC (rev 203040)
@@ -1,3 +1,16 @@
+2016-07-10  Alex Christensen  <[email protected]>
+
+        Fix client certificate authentication after r200463
+        https://bugs.webkit.org/show_bug.cgi?id=159574
+        <rdar://problem/26931006>
+
+        Reviewed by Sam Weinig.
+
+        * Shared/Authentication/mac/AuthenticationManager.mac.mm:
+        (WebKit::leafCertificate):
+        (WebKit::chain):
+        Handle the different types of CertificateInfos.
+
 2016-07-08  Yongjun Zhang  <[email protected]>
 
         When WKWebView prepares the session state blob, we should be able to filter it.

Modified: trunk/Source/WebKit2/Shared/Authentication/mac/AuthenticationManager.mac.mm (203039 => 203040)


--- trunk/Source/WebKit2/Shared/Authentication/mac/AuthenticationManager.mac.mm	2016-07-10 17:53:50 UTC (rev 203039)
+++ trunk/Source/WebKit2/Shared/Authentication/mac/AuthenticationManager.mac.mm	2016-07-10 18:48:50 UTC (rev 203040)
@@ -39,32 +39,34 @@
 static SecCertificateRef leafCertificate(const CertificateInfo& certificateInfo)
 {
 #if HAVE(SEC_TRUST_SERIALIZATION)
-    return SecTrustGetCertificateAtIndex(certificateInfo.trust(), 0);
-#else
+    if (certificateInfo.type() == CertificateInfo::Type::Trust)
+        return SecTrustGetCertificateAtIndex(certificateInfo.trust(), 0);
+#endif
+    ASSERT(certificateInfo.type() == CertificateInfo::Type::CertificateChain);
     ASSERT(CFArrayGetCount(certificateInfo.certificateChain()));
     return (SecCertificateRef)CFArrayGetValueAtIndex(certificateInfo.certificateChain(), 0);
-#endif
 }
 
 static NSArray *chain(const CertificateInfo& certificateInfo)
 {
 #if HAVE(SEC_TRUST_SERIALIZATION)
-    CFIndex count = SecTrustGetCertificateCount(certificateInfo.trust());
-    if (count < 2)
-        return nil;
+    if (certificateInfo.type() == CertificateInfo::Type::Trust) {
+        CFIndex count = SecTrustGetCertificateCount(certificateInfo.trust());
+        if (count < 2)
+            return nil;
 
-    NSMutableArray *array = [NSMutableArray array];
-    for (CFIndex i = 1; i < count; ++i)
-        [array addObject:(id)SecTrustGetCertificateAtIndex(certificateInfo.trust(), i)];
-        
-    return array;
-#else
+        NSMutableArray *array = [NSMutableArray array];
+        for (CFIndex i = 1; i < count; ++i)
+            [array addObject:(id)SecTrustGetCertificateAtIndex(certificateInfo.trust(), i)];
+            
+        return array;
+    }
+#endif
+    ASSERT(certificateInfo.type() == CertificateInfo::Type::CertificateChain);
     CFIndex chainCount = CFArrayGetCount(certificateInfo.certificateChain());
     return chainCount > 1 ? [(NSArray *)certificateInfo.certificateChain() subarrayWithRange:NSMakeRange(1, chainCount - 1)] : nil;
-#endif
 }
 
-
 // FIXME: This function creates an identity from a certificate, which should not be needed. We should pass an identity over IPC (as we do on iOS).
 bool AuthenticationManager::tryUseCertificateInfoForChallenge(const AuthenticationChallenge& challenge, const CertificateInfo& certificateInfo, const ChallengeCompletionHandler& completionHandler)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to