Programing

info.plist 파일에 NSAppTransportSecurity를 ​​어떻게 추가합니까?

crosscheck 2020. 7. 12. 09:53
반응형

info.plist 파일에 NSAppTransportSecurity를 ​​어떻게 추가합니까?


https://developer.apple.com/videos/wwdc/2015/?id=711 @ 5 : 55

info.plist에 이것을 추가 할 수없는 것 같습니다. 가치가 없습니다. XCode 버전 7.0 베타 (7A121l)를 실행하고 iOS9에서 테스트 중입니다.

동영상에서보고 싶은 URL을 구체적으로 선언 할 수 없기 때문에 "App Transport Security는 안전하지 않기 때문에 일반 텍스트 HTTP (http : //) 리소스로드를 차단했습니다. 임시 예외는 앱을 통해 구성 할 수 있습니다. Info.plist 파일 "오류.

그러나 구성 할 수없는 것 같습니다. 어떤 아이디어?


이것을 사용해보십시오 --- Xcode-beta 4 7.0에서 나를 위해 일했습니다.

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>yourdomain.com</key>
        <dict>
            <!--Include to allow subdomains-->
            <key>NSIncludesSubdomains</key>
            <true/>
            <!--Include to allow HTTP requests-->
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <!--Include to specify minimum TLS version-->
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
        </dict>
    </dict>
</dict>

또한 ATS를 비활성화하려면 다음을 사용할 수 있습니다.

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

그러나 이것은 전혀 권장되지 않습니다. 서버에는 SSL 인증서가 있어야하며 개인 정보 유출이 발생하지 않아야합니다.


info.plist 파일의 NSAppTransportSecurity 사전에서 NSAllowsArbitraryLoads 키만 YES에 추가해야합니다.

예를 들어

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

여기에 이미지 설명을 입력하십시오


그것은 나를 위해 작동하지 않았지만 이것은 트릭을 수행했습니다.

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

명확히하기 위해 ... 항상 httpS를 사용해야합니다

그러나 예외를 추가하여 무시할 수 있습니다.

여기에 이미지 설명을 입력하십시오


Xcode 8.2, iOS 10

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

답변 업데이트 (wwdc 2016 이후) :

IOS apps will require secure HTTPS connections by the end of 2016

ATS (App Transport Security)는 Apple이 iOS 9에서 도입 한 기능입니다. ATS가 활성화되면 앱이 비보안 HTTP가 아닌 HTTPS 연결을 통해 웹 서비스에 연결되도록합니다.

However, developers can still switch ATS off and allow their apps to send data over an HTTP connection as mentioned in above answers. At the end of 2016, Apple will make ATS mandatory for all developers who hope to submit their apps to the App Store. link


<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>com</key>
        <dict>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
        <key>net</key>
        <dict>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
        <key>org</key>
        <dict>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

This will allow to connect to .com .net .org


<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>uservoice.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>

To explain a bit more about ParaSara's answer: App Transport security will become mandatory and trying to turn it off may get your app rejected.

As a developer, you can turn App Transport security off if your networking code doesn't work with it, and you want to continue other development before fixing any problems. Say in a team of five, four can continue working on other things while one fixes all the problems. You can also turn App Transport security off as a debugging tool if you have networking problems and you want to check if they are caused by App Transport security. As soon as you know you should turn it on again immediately.

The solution that you must use in the future is not to use http at all, unless you use a third party server that doesn't support https. If your own server doesn't support https, Apple will have a problem with that. Even with third party servers, I wouldn't bet that Apple accepts it.

Same with the various checks for server security. At some point Apple will only accept justifiable exceptions.

But mostly, consider this: You are endangering the privacy of your customers. That's a big no-no in my book. Don't do that. Fix your code, don't ask for permission to run unsafe code.


One bad news for developers using NSAppTransportSecurity.

UPDATE:
[Apple will require HTTPS connections for iOS apps by the end of 2016]

https://techcrunch.com/2016/06/14/apple-will-require-https-connections-for-ios-apps-by-the-end-of-2016/


In mac shell command line , use the following command:

plutil -insert NSAppTransportSecurity -xml "<array><string> hidden </string></array>" [location of your xcode project]/Info.plist 

The command will add all the necessary values into your plist file.


XCODE 8, Swift 3: You need to add a row: **

"App transport Security Setting"

** in the info.plist inside information Property list.


Xcode 9.2, Swift 4, this works for me.

<key>App Transport Security Settings</key>
<dict>
    <key>Allow Arbitrary Loads</key>
    <true/>
</dict>

참고 URL : https://stackoverflow.com/questions/31216758/how-can-i-add-nsapptransportsecurity-to-my-info-plist-file

반응형