Changeset 169655 in webkit


Ignore:
Timestamp:
Jun 6, 2014 12:04:10 PM (10 years ago)
Author:
mitz@apple.com
Message:

Source/WebCore: WebCore part of <rdar://problem/17095692> [iOS] Client-certificate authentication isn’t working
https://bugs.webkit.org/show_bug.cgi?id=133527

Reviewed by Darin Adler.

  • WebCore.exp.in: Exported some Credential member functions.

Source/WebKit2: <rdar://problem/17095692> [iOS] Client-certificate authentication isn’t working
https://bugs.webkit.org/show_bug.cgi?id=133527

Reviewed by Darin Adler.

  • Configurations/Network-iOS.entitlements: Enabled the Network process to access the keys

needed to create identities to authenticate with.

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::ArgumentCoder<Credential>::encode): Encode the credential type, and if it is a client
certificate, encode the identity and the certificates.
(IPC::ArgumentCoder<Credential>::decode): Decode the credential type. If it is a client
certificate, decode the identity and the certificates and use the proper Credential
constructor.

  • Shared/cf/ArgumentCodersCF.cpp:

(IPC::typeFromCFTypeRef): Handle SecIdentityRef.
(IPC::encode): Encode an identity by encoding its certificate and a persistent reference to
its key.
(IPC::decode): Decode a certificate and a persistent reference to a key, find the key, and
create an identity.

  • Shared/cf/ArgumentCodersCF.h:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r169654 r169655  
     12014-06-06  Dan Bernstein  <mitz@apple.com>
     2
     3        WebCore part of <rdar://problem/17095692> [iOS] Client-certificate authentication isn’t working
     4        https://bugs.webkit.org/show_bug.cgi?id=133527
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebCore.exp.in: Exported some Credential member functions.
     9
    1102014-06-06  Dean Jackson  <dino@apple.com>
    211
  • trunk/Source/WebCore/WebCore.exp.in

    r169625 r169655  
    7272__ZN7WebCore10ClientRectC1ERKNS_9FloatRectE
    7373__ZN7WebCore10ClientRectC1Ev
     74__ZN7WebCore10CredentialC1EP13__SecIdentityPK9__CFArrayNS_21CredentialPersistenceE
    7475__ZN7WebCore10CredentialC1ERKN3WTF6StringES4_NS_21CredentialPersistenceE
    7576__ZN7WebCore10CredentialC1Ev
     
    15061507__ZNK7WebCore10Credential11hasPasswordEv
    15071508__ZNK7WebCore10Credential11persistenceEv
     1509__ZNK7WebCore10Credential12certificatesEv
     1510__ZNK7WebCore10Credential4typeEv
    15081511__ZNK7WebCore10Credential4userEv
    15091512__ZNK7WebCore10Credential7isEmptyEv
     1513__ZNK7WebCore10Credential8identityEv
    15101514__ZNK7WebCore10Credential8passwordEv
    15111515__ZNK7WebCore10FloatPointcv7CGPointEv
  • trunk/Source/WebKit2/ChangeLog

    r169626 r169655  
     12014-06-06  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/17095692> [iOS] Client-certificate authentication isn’t working
     4        https://bugs.webkit.org/show_bug.cgi?id=133527
     5
     6        Reviewed by Darin Adler.
     7
     8        * Configurations/Network-iOS.entitlements: Enabled the Network process to access the keys
     9        needed to create identities to authenticate with.
     10
     11        * Shared/WebCoreArgumentCoders.cpp:
     12        (IPC::ArgumentCoder<Credential>::encode): Encode the credential type, and if it is a client
     13        certificate, encode the identity and the certificates.
     14        (IPC::ArgumentCoder<Credential>::decode): Decode the credential type. If it is a client
     15        certificate, decode the identity and the certificates and use the proper Credential
     16        constructor.
     17
     18        * Shared/cf/ArgumentCodersCF.cpp:
     19        (IPC::typeFromCFTypeRef): Handle SecIdentityRef.
     20        (IPC::encode): Encode an identity by encoding its certificate and a persistent reference to
     21        its key.
     22        (IPC::decode): Decode a certificate and a persistent reference to a key, find the key, and
     23        create an identity.
     24        * Shared/cf/ArgumentCodersCF.h:
     25
    1262014-06-05  Benjamin Poulain  <bpoulain@apple.com>
    227
  • trunk/Source/WebKit2/Configurations/Network-iOS.entitlements

    r166103 r169655  
    55        <key>com.apple.private.network.socket-delegate</key>
    66        <true/>
     7        <key>keychain-access-groups</key>
     8        <array>
     9                <string>com.apple.identities</string>
     10        </array>
    711</dict>
    812</plist>
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r168845 r169655  
    7070#include <wtf/text/StringHash.h>
    7171
     72#if PLATFORM(COCOA)
     73#include "ArgumentCodersCF.h"
     74#endif
     75
    7276#if PLATFORM(IOS)
    7377#include <WebCore/FloatQuad.h>
     
    468472void ArgumentCoder<Credential>::encode(ArgumentEncoder& encoder, const Credential& credential)
    469473{
     474#if CERTIFICATE_CREDENTIALS_SUPPORTED
     475    encoder.encodeEnum(credential.type());
     476
     477    if (credential.type() == CredentialTypeClientCertificate) {
     478        IPC::encode(encoder, credential.identity());
     479
     480        encoder << !!credential.certificates();
     481        if (credential.certificates())
     482            IPC::encode(encoder, credential.certificates());
     483
     484        encoder.encodeEnum(credential.persistence());
     485        return;
     486    }
     487#endif
    470488    encoder << credential.user() << credential.password();
     489
    471490    encoder.encodeEnum(credential.persistence());
    472491}
     
    474493bool ArgumentCoder<Credential>::decode(ArgumentDecoder& decoder, Credential& credential)
    475494{
     495#if CERTIFICATE_CREDENTIALS_SUPPORTED
     496    CredentialType type;
     497
     498    if (!decoder.decodeEnum(type))
     499        return false;
     500
     501    if (type == CredentialTypeClientCertificate) {
     502        RetainPtr<SecIdentityRef> identity;
     503        if (!IPC::decode(decoder, identity))
     504            return false;
     505
     506        bool hasCertificates;
     507        if (!decoder.decode(hasCertificates))
     508            return false;
     509
     510        RetainPtr<CFArrayRef> certificates;
     511        if (hasCertificates) {
     512            if (!IPC::decode(decoder, certificates))
     513                return false;
     514        }
     515
     516        CredentialPersistence persistence;
     517        if (!decoder.decodeEnum(persistence))
     518            return false;
     519
     520        credential = Credential(identity.get(), certificates.get(), persistence);
     521        return true;
     522    }
     523#endif
     524
    476525    String user;
    477526    if (!decoder.decode(user))
  • trunk/Source/WebKit2/Shared/cf/ArgumentCodersCF.cpp

    r163886 r169655  
    3737#endif
    3838
     39#if defined(__has_include) && __has_include(<Security/SecIdentityPriv.h>)
     40#include <Security/SecIdentityPriv.h>
     41#endif
     42
     43extern "C" SecIdentityRef SecIdentityCreate(CFAllocatorRef allocator, SecCertificateRef certificate, SecKeyRef privateKey);
     44
     45#if defined(__has_include) && __has_include(<Security/SecKeyPriv.h>)
     46#include <Security/SecKeyPriv.h>
     47#endif
     48
     49extern "C" OSStatus SecKeyCopyPersistentRef(SecKeyRef key, CFDataRef* persistentRef);
     50extern "C" OSStatus SecKeyFindWithPersistentRef(CFDataRef persistentRef, SecKeyRef* lookedUpData);
     51
    3952using namespace WebCore;
    4053
     
    5871    CFURL,
    5972    SecCertificate,
     73    SecIdentity,
    6074#if HAVE(SEC_KEYCHAIN)
    6175    SecKeychainItem,
     
    93107    if (typeID == SecCertificateGetTypeID())
    94108        return SecCertificate;
     109    if (typeID == SecIdentityGetTypeID())
     110        return SecIdentity;
    95111#if HAVE(SEC_KEYCHAIN)
    96112    if (typeID == SecKeychainItemGetTypeID())
     
    136152    case SecCertificate:
    137153        encode(encoder, (SecCertificateRef)typeRef);
     154        return;
     155    case SecIdentity:
     156        encode(encoder, (SecIdentityRef)(typeRef));
    138157        return;
    139158#if HAVE(SEC_KEYCHAIN)
     
    222241            return false;
    223242        result = adoptCF(certificate.leakRef());
     243        return true;
     244    }
     245    case SecIdentity: {
     246        RetainPtr<SecIdentityRef> identity;
     247        if (!decode(decoder, identity))
     248            return false;
     249        result = adoptCF(identity.leakRef());
    224250        return true;
    225251    }
     
    556582}
    557583
     584void encode(ArgumentEncoder& encoder, SecIdentityRef identity)
     585{
     586    SecCertificateRef certificate = nullptr;
     587    SecIdentityCopyCertificate(identity, &certificate);
     588    encode(encoder, certificate);
     589    CFRelease(certificate);
     590
     591    SecKeyRef key = nullptr;
     592    SecIdentityCopyPrivateKey(identity, &key);
     593
     594    CFDataRef keyData = nullptr;
     595    SecKeyCopyPersistentRef(key, &keyData);
     596    CFRelease(key);
     597
     598    encoder << !!keyData;
     599    if (keyData) {
     600        encode(encoder, keyData);
     601        CFRelease(keyData);
     602    }
     603}
     604
     605bool decode(ArgumentDecoder& decoder, RetainPtr<SecIdentityRef>& result)
     606{
     607    RetainPtr<SecCertificateRef> certificate;
     608    if (!decode(decoder, certificate))
     609        return false;
     610
     611    bool hasKey;
     612    if (!decoder.decode(hasKey))
     613        return false;
     614
     615    if (!hasKey)
     616        return true;
     617
     618    RetainPtr<CFDataRef> keyData;
     619    if (!decode(decoder, keyData))
     620        return false;
     621
     622    SecKeyRef key = nullptr;
     623    SecKeyFindWithPersistentRef(keyData.get(), &key);
     624    if (key) {
     625        result = adoptCF(SecIdentityCreate(kCFAllocatorDefault, certificate.get(), key));
     626        CFRelease(key);
     627    }
     628
     629    return true;
     630}
     631
    558632#if HAVE(SEC_KEYCHAIN)
    559633void encode(ArgumentEncoder& encoder, SecKeychainItemRef keychainItem)
  • trunk/Source/WebKit2/Shared/cf/ArgumentCodersCF.h

    r161148 r169655  
    7979bool decode(ArgumentDecoder&, RetainPtr<SecCertificateRef>& result);
    8080
     81// SecIdentityRef
     82void encode(ArgumentEncoder&, SecIdentityRef);
     83bool decode(ArgumentDecoder&, RetainPtr<SecIdentityRef>& result);
     84
    8185#if HAVE(SEC_KEYCHAIN)
    8286// SecKeychainItemRef
Note: See TracChangeset for help on using the changeset viewer.