Changeset 263724 in webkit


Ignore:
Timestamp:
Jun 29, 2020 9:39:50 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Make _WKWebsiteDataStoreConfiguration SPI for HSTS storage to replace _WKProcessPoolConfiguration.hstsStorageDirectory
https://bugs.webkit.org/show_bug.cgi?id=213048

Patch by Alex Christensen <achristensen@webkit.org> on 2020-06-29
Reviewed by Youenn Fablet.

Source/WebCore/PAL:

  • pal/spi/cf/CFNetworkSPI.h:

Source/WebKit:

This uses CFNetwork SPI introduced in rdar://problem/50109631 to allow HSTS storage per NSURLSession.
To be complete, I also deprecated our UI process HSTS state removal attempt SPIs, WKContextResetHSTSHosts and
WKContextResetHSTSHostsAddedAfterDate, which had their last use removed in rdar://problem/64220838.

I manually verified that this new SPI puts HSTS data in the specified location, and I also verified that HSTS
state querying and removal works with the new CFNetwork SPI as it did with the old one.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::fetchWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteData):
(WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
(WebKit::NetworkProcess::deleteAndRestrictWebsiteDataForRegistrableDomains):
(WebKit::NetworkProcess::registrableDomainsWithWebsiteData):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkSessionCreationParameters.cpp:

(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):

  • NetworkProcess/NetworkSessionCreationParameters.h:
  • NetworkProcess/cocoa/NetworkProcessCocoa.mm:

(WebKit::NetworkProcess::hostNamesWithHSTSCache const):
(WebKit::NetworkProcess::deleteHSTSCacheForHostNames):
(WebKit::NetworkProcess::clearHSTSCache):
(WebKit::NetworkProcess::getHostNamesWithHSTSCache): Deleted.

  • NetworkProcess/cocoa/NetworkSessionCocoa.h:
  • NetworkProcess/cocoa/NetworkSessionCocoa.mm:

(WebKit::NetworkSessionCocoa::hstsStorage const):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):

  • NetworkProcess/soup/NetworkProcessSoup.cpp:

(WebKit::NetworkProcess::hostNamesWithHSTSCache const):
(WebKit::NetworkProcess::deleteHSTSCacheForHostNames):
(WebKit::NetworkProcess::clearHSTSCache):
(WebKit::NetworkProcess::getHostNamesWithHSTSCache): Deleted.

  • UIProcess/API/C/mac/WKContextPrivateMac.h:
  • UIProcess/API/C/mac/WKContextPrivateMac.mm:

(WKContextResetHSTSHosts):
(WKContextResetHSTSHostsAddedAfterDate):

  • UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
  • UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
  • UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:

(-[_WKWebsiteDataStoreConfiguration hstsStorageDirectory]):
(-[_WKWebsiteDataStoreConfiguration setHSTSStorageDirectory:]):

  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::privateBrowsingSession): Deleted.
(WebKit::WebProcessPool::resetHSTSHosts): Deleted.
(WebKit::WebProcessPool::resetHSTSHostsAddedAfterDate): Deleted.

  • UIProcess/WebProcessPool.h:
  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::resolveDirectoriesIfNecessary):
(WebKit::WebsiteDataStore::parameters):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

(WebKit::WebsiteDataStore::resolvedHSTSStorageDirectory const):

  • UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:

(WebKit::WebsiteDataStoreConfiguration::copy const):

  • UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:

Source/WTF:

  • wtf/PlatformHave.h:
Location:
trunk/Source
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r263723 r263724  
     12020-06-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        Make _WKWebsiteDataStoreConfiguration SPI for HSTS storage to replace _WKProcessPoolConfiguration.hstsStorageDirectory
     4        https://bugs.webkit.org/show_bug.cgi?id=213048
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * wtf/PlatformHave.h:
     9
    1102020-06-29  Geoffrey Garen  <ggaren@apple.com>
    211
  • trunk/Source/WTF/wtf/PlatformHave.h

    r263380 r263724  
    408408#endif
    409409
     410#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) \
     411    || ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) \
     412    || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 70000) \
     413    || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 140000)
     414#define HAVE_HSTS_STORAGE 1
     415#endif
     416
    410417#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
    411418#define HAVE_CFNETWORK_METRICS_APIS_V4 1
  • trunk/Source/WebCore/PAL/ChangeLog

    r263700 r263724  
     12020-06-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        Make _WKWebsiteDataStoreConfiguration SPI for HSTS storage to replace _WKProcessPoolConfiguration.hstsStorageDirectory
     4        https://bugs.webkit.org/show_bug.cgi?id=213048
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * pal/spi/cf/CFNetworkSPI.h:
     9
    1102020-06-29  Tetsuharu Ohzeki  <tetsuharu.ohzeki@gmail.com>
    211
  • trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h

    r262930 r263724  
    408408Boolean _CFNetworkSetATSContext(CFDataRef);
    409409
    410 #if PLATFORM(COCOA)
     410#if PLATFORM(COCOA) && !HAVE(HSTS_STORAGE)
    411411extern const CFStringRef _kCFNetworkHSTSPreloaded;
    412412CFDictionaryRef _CFNetworkCopyHSTSPolicies(CFURLStorageSessionRef);
     
    459459@end
    460460
     461#if HAVE(HSTS_STORAGE)
     462@interface _NSHSTSStorage : NSObject
     463-(instancetype)initPersistentStoreWithURL:(nullable NSURL*)path;
     464-(BOOL)shouldPromoteHostToHTTPS:(NSString *)host;
     465-(NSArray<NSString *> *)nonPreloadedHosts;
     466-(void)resetHSTSForHost:(NSString *)host;
     467-(void)resetHSTSHostsSinceDate:(NSDate *)date;
     468@end
     469#endif
     470
    461471@interface NSURLSessionConfiguration ()
    462472// FIXME: Remove this once rdar://problem/40650244 is in a build.
    463473@property (copy) NSDictionary *_socketStreamProperties;
     474#if HAVE(HSTS_STORAGE)
     475@property (nullable, retain) _NSHSTSStorage *_hstsStorage;
     476#endif
    464477@end
    465478
  • trunk/Source/WebKit/ChangeLog

    r263721 r263724  
     12020-06-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        Make _WKWebsiteDataStoreConfiguration SPI for HSTS storage to replace _WKProcessPoolConfiguration.hstsStorageDirectory
     4        https://bugs.webkit.org/show_bug.cgi?id=213048
     5
     6        Reviewed by Youenn Fablet.
     7
     8        This uses CFNetwork SPI introduced in rdar://problem/50109631 to allow HSTS storage per NSURLSession.
     9        To be complete, I also deprecated our UI process HSTS state removal attempt SPIs, WKContextResetHSTSHosts and
     10        WKContextResetHSTSHostsAddedAfterDate, which had their last use removed in rdar://problem/64220838.
     11
     12        I manually verified that this new SPI puts HSTS data in the specified location, and I also verified that HSTS
     13        state querying and removal works with the new CFNetwork SPI as it did with the old one.
     14
     15        * NetworkProcess/NetworkProcess.cpp:
     16        (WebKit::NetworkProcess::fetchWebsiteData):
     17        (WebKit::NetworkProcess::deleteWebsiteData):
     18        (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
     19        (WebKit::NetworkProcess::deleteAndRestrictWebsiteDataForRegistrableDomains):
     20        (WebKit::NetworkProcess::registrableDomainsWithWebsiteData):
     21        * NetworkProcess/NetworkProcess.h:
     22        * NetworkProcess/NetworkSessionCreationParameters.cpp:
     23        (WebKit::NetworkSessionCreationParameters::encode const):
     24        (WebKit::NetworkSessionCreationParameters::decode):
     25        * NetworkProcess/NetworkSessionCreationParameters.h:
     26        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
     27        (WebKit::NetworkProcess::hostNamesWithHSTSCache const):
     28        (WebKit::NetworkProcess::deleteHSTSCacheForHostNames):
     29        (WebKit::NetworkProcess::clearHSTSCache):
     30        (WebKit::NetworkProcess::getHostNamesWithHSTSCache): Deleted.
     31        * NetworkProcess/cocoa/NetworkSessionCocoa.h:
     32        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     33        (WebKit::NetworkSessionCocoa::hstsStorage const):
     34        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
     35        * NetworkProcess/soup/NetworkProcessSoup.cpp:
     36        (WebKit::NetworkProcess::hostNamesWithHSTSCache const):
     37        (WebKit::NetworkProcess::deleteHSTSCacheForHostNames):
     38        (WebKit::NetworkProcess::clearHSTSCache):
     39        (WebKit::NetworkProcess::getHostNamesWithHSTSCache): Deleted.
     40        * UIProcess/API/C/mac/WKContextPrivateMac.h:
     41        * UIProcess/API/C/mac/WKContextPrivateMac.mm:
     42        (WKContextResetHSTSHosts):
     43        (WKContextResetHSTSHostsAddedAfterDate):
     44        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
     45        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
     46        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
     47        (-[_WKWebsiteDataStoreConfiguration hstsStorageDirectory]):
     48        (-[_WKWebsiteDataStoreConfiguration setHSTSStorageDirectory:]):
     49        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     50        (WebKit::privateBrowsingSession): Deleted.
     51        (WebKit::WebProcessPool::resetHSTSHosts): Deleted.
     52        (WebKit::WebProcessPool::resetHSTSHostsAddedAfterDate): Deleted.
     53        * UIProcess/WebProcessPool.h:
     54        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     55        (WebKit::WebsiteDataStore::resolveDirectoriesIfNecessary):
     56        (WebKit::WebsiteDataStore::parameters):
     57        * UIProcess/WebsiteData/WebsiteDataStore.h:
     58        (WebKit::WebsiteDataStore::resolvedHSTSStorageDirectory const):
     59        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
     60        (WebKit::WebsiteDataStoreConfiguration::copy const):
     61        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
     62
    1632020-06-29  Tim Horton  <timothy_horton@apple.com>
    264
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r263422 r263724  
    15351535
    15361536#if PLATFORM(COCOA) || USE(SOUP)
    1537     if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1538         if (auto* networkStorageSession = storageSession(sessionID))
    1539             getHostNamesWithHSTSCache(*networkStorageSession, callbackAggregator->m_websiteData.hostNamesWithHSTSCache);
    1540     }
     1537    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache))
     1538        callbackAggregator->m_websiteData.hostNamesWithHSTSCache = hostNamesWithHSTSCache(sessionID);
    15411539#endif
    15421540
     
    15971595{
    15981596#if PLATFORM(COCOA) || USE(SOUP)
    1599     if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1600         if (auto* networkStorageSession = storageSession(sessionID))
    1601             clearHSTSCache(*networkStorageSession, modifiedSince);
    1602     }
     1597    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache))
     1598        clearHSTSCache(sessionID, modifiedSince);
    16031599#endif
    16041600
     
    17021698
    17031699#if PLATFORM(COCOA) || USE(SOUP)
    1704     if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1705         if (auto* networkStorageSession = storageSession(sessionID))
    1706             deleteHSTSCacheForHostNames(*networkStorageSession, HSTSCacheHostNames);
    1707     }
     1700    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache))
     1701        deleteHSTSCacheForHostNames(sessionID, HSTSCacheHostNames);
    17081702#endif
    17091703
     
    18731867#if PLATFORM(COCOA) || USE(SOUP)
    18741868    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    1875         if (auto* networkStorageSession = storageSession(sessionID)) {
    1876             getHostNamesWithHSTSCache(*networkStorageSession, hostNamesWithHSTSCache);
    1877             hostnamesWithHSTSToDelete = filterForRegistrableDomains(domainsToDeleteAllNonCookieWebsiteDataFor, hostNamesWithHSTSCache);
    1878 
    1879             for (const auto& host : hostnamesWithHSTSToDelete)
    1880                 callbackAggregator->m_domains.add(RegistrableDomain::uncheckedCreateFromHost(host));
    1881 
    1882             deleteHSTSCacheForHostNames(*networkStorageSession, hostnamesWithHSTSToDelete);
    1883         }
     1869        hostNamesWithHSTSCache = this->hostNamesWithHSTSCache(sessionID);
     1870        hostnamesWithHSTSToDelete = filterForRegistrableDomains(domainsToDeleteAllNonCookieWebsiteDataFor, hostNamesWithHSTSCache);
     1871
     1872        for (const auto& host : hostnamesWithHSTSToDelete)
     1873            callbackAggregator->m_domains.add(RegistrableDomain::uncheckedCreateFromHost(host));
     1874
     1875        deleteHSTSCacheForHostNames(sessionID, hostnamesWithHSTSToDelete);
    18841876    }
    18851877#endif
     
    20582050    }));
    20592051   
    2060     auto& websiteDataStore = callbackAggregator->m_websiteData;
     2052    auto& websiteData = callbackAggregator->m_websiteData;
    20612053   
    20622054    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
    20632055        if (auto* networkStorageSession = storageSession(sessionID))
    2064             networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies);
     2056            networkStorageSession->getHostnamesWithCookies(websiteData.hostNamesWithCookies);
    20652057    }
    20662058   
    20672059#if PLATFORM(COCOA) || USE(SOUP)
    2068     if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
    2069         if (auto* networkStorageSession = storageSession(sessionID))
    2070             getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache);
    2071     }
     2060    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache))
     2061        websiteData.hostNamesWithHSTSCache = hostNamesWithHSTSCache(sessionID);
    20722062#endif
    20732063
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r263444 r263724  
    194194#endif
    195195#if PLATFORM(COCOA) || USE(SOUP)
    196     void getHostNamesWithHSTSCache(WebCore::NetworkStorageSession&, HashSet<String>&);
    197     void deleteHSTSCacheForHostNames(WebCore::NetworkStorageSession&, const Vector<String>&);
    198     void clearHSTSCache(WebCore::NetworkStorageSession&, WallTime modifiedSince);
     196    HashSet<String> hostNamesWithHSTSCache(PAL::SessionID) const;
     197    void deleteHSTSCacheForHostNames(PAL::SessionID, const Vector<String>&);
     198    void clearHSTSCache(PAL::SessionID, WallTime modifiedSince);
    199199#endif
    200200
  • trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp

    r263444 r263724  
    5858    encoder << http3Enabled;
    5959#endif
     60    encoder << hstsStorageDirectory;
     61    encoder << hstsStorageDirectoryExtensionHandle;
    6062#if USE(SOUP)
    6163    encoder << cookiePersistentStoragePath;
     
    154156#endif
    155157
     158    Optional<String> hstsStorageDirectory;
     159    decoder >> hstsStorageDirectory;
     160    if (!hstsStorageDirectory)
     161        return WTF::nullopt;
     162
     163    Optional<SandboxExtension::Handle> hstsStorageDirectoryExtensionHandle;
     164    decoder >> hstsStorageDirectoryExtensionHandle;
     165    if (!hstsStorageDirectoryExtensionHandle)
     166        return WTF::nullopt;
     167   
    156168#if USE(SOUP)
    157169    Optional<String> cookiePersistentStoragePath;
     
    276288        , WTFMove(*http3Enabled)
    277289#endif
     290        , WTFMove(*hstsStorageDirectory)
     291        , WTFMove(*hstsStorageDirectoryExtensionHandle)
    278292#if USE(SOUP)
    279293        , WTFMove(*cookiePersistentStoragePath)
  • trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h

    r263444 r263724  
    7070    bool http3Enabled { false };
    7171#endif
     72    String hstsStorageDirectory;
     73    SandboxExtension::Handle hstsStorageDirectoryExtensionHandle;
    7274#if USE(SOUP)
    7375    String cookiePersistentStoragePath;
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm

    r263551 r263724  
    135135}
    136136
     137#if !HAVE(HSTS_STORAGE)
    137138static void filterPreloadHSTSEntry(const void* key, const void* value, void* context)
    138139{
     
    153154        hostnames->add((CFStringRef)key);
    154155}
    155 
    156 void NetworkProcess::getHostNamesWithHSTSCache(WebCore::NetworkStorageSession& session, HashSet<String>& hostNames)
    157 {
    158     if (auto HSTSPolicies = adoptCF(_CFNetworkCopyHSTSPolicies(session.platformSession())))
    159         CFDictionaryApplyFunction(HSTSPolicies.get(), filterPreloadHSTSEntry, &hostNames);
    160 }
    161 
    162 void NetworkProcess::deleteHSTSCacheForHostNames(WebCore::NetworkStorageSession& session, const Vector<String>& hostNames)
    163 {
    164     for (auto& hostName : hostNames) {
    165         auto url = URL({ }, makeString("https://", hostName));
    166         _CFNetworkResetHSTS(url.createCFURL().get(), session.platformSession());
    167     }
    168 }
    169 
    170 void NetworkProcess::clearHSTSCache(WebCore::NetworkStorageSession& session, WallTime modifiedSince)
     156#endif
     157
     158HashSet<String> NetworkProcess::hostNamesWithHSTSCache(PAL::SessionID sessionID) const
     159{
     160    HashSet<String> hostNames;
     161#if HAVE(HSTS_STORAGE)
     162    if (auto* networkSession = static_cast<NetworkSessionCocoa*>(this->networkSession(sessionID))) {
     163        for (NSString *host in networkSession->hstsStorage().nonPreloadedHosts)
     164            hostNames.add(host);
     165    }
     166#else
     167    if (auto* session = storageSession(sessionID)) {
     168        if (auto HSTSPolicies = adoptCF(_CFNetworkCopyHSTSPolicies(session->platformSession())))
     169            CFDictionaryApplyFunction(HSTSPolicies.get(), filterPreloadHSTSEntry, &hostNames);
     170    }
     171#endif
     172    return hostNames;
     173}
     174
     175void NetworkProcess::deleteHSTSCacheForHostNames(PAL::SessionID sessionID, const Vector<String>& hostNames)
     176{
     177#if HAVE(HSTS_STORAGE)
     178    if (auto* networkSession = static_cast<NetworkSessionCocoa*>(this->networkSession(sessionID))) {
     179        for (auto& hostName : hostNames)
     180            [networkSession->hstsStorage() resetHSTSForHost:hostName];
     181    }
     182#else
     183    if (auto* session = storageSession(sessionID)) {
     184        for (auto& hostName : hostNames) {
     185            auto url = URL({ }, makeString("https://", hostName));
     186            _CFNetworkResetHSTS(url.createCFURL().get(), session->platformSession());
     187        }
     188    }
     189#endif
     190}
     191
     192void NetworkProcess::clearHSTSCache(PAL::SessionID sessionID, WallTime modifiedSince)
    171193{
    172194    NSTimeInterval timeInterval = modifiedSince.secondsSinceEpoch().seconds();
    173195    NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
    174 
    175     _CFNetworkResetHSTSHostsSinceDate(session.platformSession(), (__bridge CFDateRef)date);
     196#if HAVE(HSTS_STORAGE)
     197    if (auto* networkSession = static_cast<NetworkSessionCocoa*>(this->networkSession(sessionID)))
     198        [networkSession->hstsStorage() resetHSTSHostsSinceDate:date];
     199#else
     200    if (auto* session = storageSession(sessionID))
     201        _CFNetworkResetHSTSHostsSinceDate(session->platformSession(), (__bridge CFDateRef)date);
     202#endif
    176203}
    177204
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h

    r263122 r263724  
    3434OBJC_CLASS WKNetworkSessionDelegate;
    3535OBJC_CLASS WKNetworkSessionWebSocketDelegate;
     36OBJC_CLASS _NSHSTSStorage;
    3637
    3738#include "DownloadID.h"
     
    105106    void taskFailed(NetworkDataTaskCocoa::TaskIdentifier);
    106107    NSURLCredential *successfulClientCertificateForHost(const String& host, uint16_t port) const;
     108    _NSHSTSStorage *hstsStorage() const;
    107109
    108110private:
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r263460 r263724  
    6868
    6969#import "DeviceManagementSoftLink.h"
     70
     71// FIXME: Remove this soft link once rdar://problem/50109631 is in a build and bots are updated.
     72SOFT_LINK_FRAMEWORK(CFNetwork)
     73SOFT_LINK_CLASS_OPTIONAL(CFNetwork, _NSHSTSStorage)
    7074
    7175using namespace WebKit;
     
    10931097}
    10941098
     1099_NSHSTSStorage *NetworkSessionCocoa::hstsStorage() const
     1100{
     1101#if HAVE(HSTS_STORAGE)
     1102    NSURLSessionConfiguration *configuration = m_sessionWithCredentialStorage.session.get().configuration;
     1103    // FIXME: Remove this respondsToSelector check once rdar://problem/50109631 is in a build and bots are updated.
     1104    if ([configuration respondsToSelector:@selector(_hstsStorage)])
     1105        return m_sessionWithCredentialStorage.session.get().configuration._hstsStorage;
     1106#endif
     1107    return nil;
     1108}
     1109
    10951110const String& NetworkSessionCocoa::boundInterfaceIdentifier() const
    10961111{
     
    11721187
    11731188    NSURLSessionConfiguration *configuration = configurationForSessionID(m_sessionID);
     1189
     1190#if HAVE(HSTS_STORAGE)
     1191    if (!!parameters.hstsStorageDirectory && !m_sessionID.isEphemeral()) {
     1192        SandboxExtension::consumePermanently(parameters.hstsStorageDirectoryExtensionHandle);
     1193        // FIXME: Remove this respondsToSelector check once rdar://problem/50109631 is in a build and bots are updated.
     1194        if ([configuration respondsToSelector:@selector(_hstsStorage)])
     1195            configuration._hstsStorage = [[alloc_NSHSTSStorageInstance() initPersistentStoreWithURL:[NSURL fileURLWithPath:parameters.hstsStorageDirectory isDirectory:YES]] autorelease];
     1196    }
     1197#endif
    11741198
    11751199#if HAVE(APP_SSO) || PLATFORM(MACCATALYST)
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp

    r263444 r263724  
    9595}
    9696
    97 void NetworkProcess::getHostNamesWithHSTSCache(WebCore::NetworkStorageSession& storageSession, HashSet<String>& hostNames)
    98 {
    99     const auto* session = static_cast<NetworkSessionSoup*>(networkSession(storageSession.sessionID()));
     97HashSet<String> NetworkProcess::hostNamesWithHSTSCache(PAL::SessionID sessionID) const
     98{
     99    HashSet<String> hostNames;
     100    const auto* session = static_cast<NetworkSessionSoup*>(networkSession(sessionID));
    100101    session->soupNetworkSession().getHostNamesWithHSTSCache(hostNames);
    101 }
    102 
    103 void NetworkProcess::deleteHSTSCacheForHostNames(WebCore::NetworkStorageSession& storageSession, const Vector<String>& hostNames)
    104 {
    105     const auto* session = static_cast<NetworkSessionSoup*>(networkSession(storageSession.sessionID()));
     102    return hostNames;
     103}
     104
     105void NetworkProcess::deleteHSTSCacheForHostNames(PAL::SessionID sessionID, const Vector<String>& hostNames)
     106{
     107    const auto* session = static_cast<NetworkSessionSoup*>(networkSession(sessionID));
    106108    session->soupNetworkSession().deleteHSTSCacheForHostNames(hostNames);
    107109}
    108110
    109 void NetworkProcess::clearHSTSCache(WebCore::NetworkStorageSession& storageSession, WallTime modifiedSince)
    110 {
    111     const auto* session = static_cast<NetworkSessionSoup*>(networkSession(storageSession.sessionID()));
     111void NetworkProcess::clearHSTSCache(PAL::SessionID sessionID, WallTime modifiedSince)
     112{
     113    const auto* session = static_cast<NetworkSessionSoup*>(networkSession(sessionID));
    112114    session->soupNetworkSession().clearHSTSCache(modifiedSince);
    113115}
  • trunk/Source/WebKit/UIProcess/API/C/mac/WKContextPrivateMac.h

    r234960 r263724  
    2828
    2929#include <WebKit/WKBase.h>
     30#include <WebKit/WKDeprecated.h>
    3031#include <WebKit/WKPluginLoadPolicy.h>
    3132
     
    4445WK_EXPORT void WKContextGetInfoForInstalledPlugIns(WKContextRef context, WKContextGetInfoForInstalledPlugInsBlock block);
    4546
    46 WK_EXPORT void WKContextResetHSTSHosts(WKContextRef context);
    47 
    48 // The time here is relative to the Unix epoch.
    49 WK_EXPORT void WKContextResetHSTSHostsAddedAfterDate(WKContextRef context, double startDateIntervalSince1970);
     47WK_EXPORT void WKContextResetHSTSHosts(WKContextRef context) WK_C_API_DEPRECATED;
     48WK_EXPORT void WKContextResetHSTSHostsAddedAfterDate(WKContextRef context, double startDateIntervalSince1970) WK_C_API_DEPRECATED;
    5049
    5150WK_EXPORT void WKContextRegisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme);
  • trunk/Source/WebKit/UIProcess/API/C/mac/WKContextPrivateMac.mm

    r262826 r263724  
    102102}
    103103
    104 void WKContextResetHSTSHosts(WKContextRef context)
     104void WKContextResetHSTSHosts(WKContextRef)
    105105{
    106     return WebKit::toImpl(context)->resetHSTSHosts();
    107106}
    108107
    109 void WKContextResetHSTSHostsAddedAfterDate(WKContextRef context, double startDateIntervalSince1970)
     108void WKContextResetHSTSHostsAddedAfterDate(WKContextRef, double)
    110109{
    111     return WebKit::toImpl(context)->resetHSTSHostsAddedAfterDate(startDateIntervalSince1970);
    112110}
    113111
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h

    r260334 r263724  
    6969@property (nonatomic) BOOL pageCacheEnabled WK_API_AVAILABLE(macos(10.14), ios(12.0));
    7070@property (nonatomic, getter=isJITEnabled) BOOL JITEnabled WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
    71 @property (nonatomic, nullable, copy, setter=setHSTSStorageDirectory:) NSURL *hstsStorageDirectory WK_API_AVAILABLE(macos(10.15), ios(13.0));
     71@property (nonatomic, nullable, copy, setter=setHSTSStorageDirectory:) NSURL *hstsStorageDirectory WK_API_DEPRECATED_WITH_REPLACEMENT("_WKWebsiteDataStoreConfiguration.hstsStorageDirectory", macos(10.15, WK_MAC_TBA), ios(13.0, WK_IOS_TBA));
    7272
    7373@property (nonatomic) BOOL configureJSCForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h

    r260334 r263724  
    7373@property (nonatomic) BOOL suppressesConnectionTerminationOnSystemChange WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    7474@property (nonatomic) BOOL allowsServerPreconnect WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
     75@property (nonatomic, nullable, copy, setter=setHSTSStorageDirectory:) NSURL *hstsStorageDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    7576
    7677@property (nonatomic, nullable, copy) NSURL *alternativeServicesStorageDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm

    r260169 r263724  
    291291}
    292292
     293- (NSURL *)hstsStorageDirectory
     294{
     295    return [NSURL fileURLWithPath:_configuration->hstsStorageDirectory() isDirectory:YES];
     296}
     297
     298- (void)setHSTSStorageDirectory:(NSURL *)url
     299{
     300    if (!_configuration->isPersistent())
     301        [NSException raise:NSInvalidArgumentException format:@"Cannot set mediaKeysStorageDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
     302    checkURLArgument(url);
     303    _configuration->setHSTSStorageDirectory(url.path);
     304}
     305
    293306- (NSURL *)alternativeServicesStorageDirectory
    294307{
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r263636 r263724  
    729729}
    730730
    731 static CFURLStorageSessionRef privateBrowsingSession()
    732 {
    733     static CFURLStorageSessionRef session;
    734     static dispatch_once_t once;
    735     dispatch_once(&once, ^{
    736         NSString *identifier = [NSString stringWithFormat:@"%@.PrivateBrowsing", [[NSBundle mainBundle] bundleIdentifier]];
    737         session = createPrivateStorageSession((__bridge CFStringRef)identifier);
    738     });
    739 
    740     return session;
    741 }
    742 
    743731bool WebProcessPool::isURLKnownHSTSHost(const String& urlString) const
    744732{
     
    746734
    747735    return _CFNetworkIsKnownHSTSHostWithSession(url.get(), nullptr);
    748 }
    749 
    750 void WebProcessPool::resetHSTSHosts()
    751 {
    752     _CFNetworkResetHSTSHostsWithSession(nullptr);
    753     _CFNetworkResetHSTSHostsWithSession(privateBrowsingSession());
    754 }
    755 
    756 void WebProcessPool::resetHSTSHostsAddedAfterDate(double startDateIntervalSince1970)
    757 {
    758     NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:startDateIntervalSince1970];
    759     _CFNetworkResetHSTSHostsSinceDate(nullptr, (__bridge CFDateRef)startDate);
    760     _CFNetworkResetHSTSHostsSinceDate(privateBrowsingSession(), (__bridge CFDateRef)startDate);
    761736}
    762737
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r263383 r263724  
    423423
    424424    bool isURLKnownHSTSHost(const String& urlString) const;
    425     void resetHSTSHosts();
    426     void resetHSTSHostsAddedAfterDate(double startDateIntervalSince1970);
    427425
    428426    static void registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r263570 r263724  
    233233    if (!m_configuration->cacheStorageDirectory().isEmpty() && m_resolvedConfiguration->cacheStorageDirectory().isEmpty())
    234234        m_resolvedConfiguration->setCacheStorageDirectory(resolvePathForSandboxExtension(m_configuration->cacheStorageDirectory()));
     235    if (!m_configuration->hstsStorageDirectory().isEmpty() && m_resolvedConfiguration->hstsStorageDirectory().isEmpty())
     236        m_resolvedConfiguration->setHSTSStorageDirectory(resolvePathForSandboxExtension(m_configuration->hstsStorageDirectory()));
    235237
    236238    // Resolve directories for file paths.
     
    22602262        SandboxExtension::createHandleForReadWriteDirectory(networkCacheDirectory, networkCacheDirectoryExtensionHandle);
    22612263
     2264    auto hstsStorageDirectory = resolvedHSTSStorageDirectory();
     2265    SandboxExtension::Handle hstsStorageDirectoryExtensionHandle;
     2266    if (!hstsStorageDirectory.isEmpty())
     2267        SandboxExtension::createHandleForReadWriteDirectory(hstsStorageDirectory, hstsStorageDirectoryExtensionHandle);
     2268
    22622269    bool shouldIncludeLocalhostInResourceLoadStatistics = false;
    22632270    bool enableResourceLoadStatisticsDebugMode = false;
     
    23012308    networkSessionParameters.networkCacheDirectory = WTFMove(networkCacheDirectory);
    23022309    networkSessionParameters.networkCacheDirectoryExtensionHandle = WTFMove(networkCacheDirectoryExtensionHandle);
     2310    networkSessionParameters.hstsStorageDirectory = WTFMove(hstsStorageDirectory);
     2311    networkSessionParameters.hstsStorageDirectoryExtensionHandle = WTFMove(hstsStorageDirectoryExtensionHandle);
    23032312    networkSessionParameters.dataConnectionServiceType = m_configuration->dataConnectionServiceType();
    23042313    networkSessionParameters.fastServerTrustEvaluationEnabled = m_configuration->fastServerTrustEvaluationEnabled();
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r263444 r263724  
    225225    const String& resolvedServiceWorkerRegistrationDirectory() const { return m_resolvedConfiguration->serviceWorkerRegistrationDirectory(); }
    226226    const String& resolvedResourceLoadStatisticsDirectory() const { return m_resolvedConfiguration->resourceLoadStatisticsDirectory(); }
     227    const String& resolvedHSTSStorageDirectory() const { return m_resolvedConfiguration->hstsStorageDirectory(); }
    227228
    228229    DeviceIdHashSaltStorage& deviceIdHashSaltStorage() { return m_deviceIdHashSaltStorage.get(); }
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp

    r260169 r263724  
    6868    copy->m_serviceWorkerRegistrationDirectory = this->m_serviceWorkerRegistrationDirectory;
    6969    copy->m_webSQLDatabaseDirectory = this->m_webSQLDatabaseDirectory;
    70 #if USE(GLIB)
    7170    copy->m_hstsStorageDirectory = this->m_hstsStorageDirectory;
    72 #endif
    7371    copy->m_localStorageDirectory = this->m_localStorageDirectory;
    7472    copy->m_mediaKeysStorageDirectory = this->m_mediaKeysStorageDirectory;
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h

    r263269 r263724  
    6767    const String& webSQLDatabaseDirectory() const { return m_webSQLDatabaseDirectory; }
    6868    void setWebSQLDatabaseDirectory(String&& directory) { m_webSQLDatabaseDirectory = WTFMove(directory); }
    69 #if USE(GLIB) // According to r245075 this will eventually move here.
     69
    7070    const String& hstsStorageDirectory() const { return m_hstsStorageDirectory; }
    7171    void setHSTSStorageDirectory(String&& directory) { m_hstsStorageDirectory = WTFMove(directory); }
    72 #endif
     72
    7373    const String& localStorageDirectory() const { return m_localStorageDirectory; }
    7474    void setLocalStorageDirectory(String&& directory) { m_localStorageDirectory = WTFMove(directory); }
     
    175175    String m_serviceWorkerRegistrationDirectory;
    176176    String m_webSQLDatabaseDirectory;
     177    String m_hstsStorageDirectory;
    177178#if USE(GLIB)
    178     String m_hstsStorageDirectory;
    179179    bool m_networkCacheSpeculativeValidationEnabled { true };
    180180#else
Note: See TracChangeset for help on using the changeset viewer.