2016-10-27 41 views
6

蘋果已宣佈NSAllowArbitraryLoads不會很快起作用。因此,在iOS的10,我有這個在我的info.plist:iOS 9和iOS 10中的應用程序傳輸安全問題

<key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSExceptionDomains</key> 
     <dict> 
      <key>myAPIdomain</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> 
       <true/> 
       <key>NSExceptionAllowsInsecureHTTPLoads</key> 
       <true/> 
      </dict> 
     </dict> 
     <key>NSAllowsArbitraryLoadsInWebContent</key> 
     <true/> 
    </dict> 

這適用於在一個UIWebView我的API請求和內容。但是,在iOS9中,不支持NSAllowsArbitraryLoadsInWebContent,因此建議在iOS 9支持中包含NSAllowsArbitraryLoads。但我認爲這會覆蓋我的NSExceptionDomains設置?我如何使我的API和UIWebView的HTTP請求在iOS 9和iOS 10上都能工作,並且仍然遵循Apple的規則?

編輯

對於支持的iOS 9和iOS 10:

<key>NSAppTransportSecurity</key> 
     <dict> 
      <key>NSExceptionDomains</key> 
      <dict> 
       <key>myAPIdomain</key> 
       <dict> 
        <key>NSIncludesSubdomains</key> 
        <true/> 
        <key>NSExceptionAllowsInsecureHTTPLoads</key> 
        <true/> 
       </dict> 
      </dict> 
      <key>NSAllowsArbitraryLoadsInWebContent</key> 
      <true/> 
      <key>NSAllowsArbitraryLoads</key> 
      <true/> 
     </dict> 
+1

如果您支持早於iOS 10的版本,那麼您需要使用'NSAllowsArbitraryLoads',並且這將適用於iOS 9和10.您只需包含您的評論註釋了爲什麼您需要'NSAllowsArbitraryLoads'如果您有特定的域名,而您知道https將起作用,則可以爲這些域名添加例外,以便您可以快速回復https – Paulw11

+0

@ Paulw11Thanks。這意味着我只需要添加'NSAllowsArbitraryLoadsInWebContent'和'NSAllowsArbitraryLoads'到我的info.plist? – chengsam

+0

是的,這是正確的 – Paulw11

回答

1
<key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSAllowsArbitraryLoads</key> 
     <true/> 
    </dict> 

可以使用上述條件,如果你不想支持https(TLS 1.2)。但是你必須確保它是一個臨時的解決方案。從早期的2017年蘋果使https(TLS 1.2)成爲強制性的

+0

這是不正確的。你將能夠繼續使用'NSAllowsArbitraryLoads',但你需要解釋爲什麼它是必需的 – Paulw11

+0

我知道蘋果將嚴格使用2017年的'NSAllowsArbitraryLoads'。但是我也想支持iOS 9。似乎支持iOS 9必須使用'NSAllowsArbitraryLoads'。 – chengsam

+0

另外還有很多設備,例如嵌入/ IoT設備,它們永遠不會支持TLS – Paulw11