web-dev-qa-db-ja.com

NSExceptionDomainsをxcodeバージョン7.0.1のplistに追加するにはどうすればよいですか?

Xcodeバージョン7.0.1を使用してHTMLベースのWebサイトをiPhoneアプリとしてバンドルしたいのですが、すべて正常に機能します。唯一の問題は、iPhone 4sでアプリケーションをテストすると、http。ただし、その画像へのhttpsアクセスを提供する別のWebサイトの画像にアクセスすることはできました。

バンドルにhttpサポートを追加する方法はありますか?

更新

PlistファイルにNSExceptionDomainsを追加しましたが、それでも同じ問題が発生します

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.Apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleDisplayName</key>
    <string>My Project</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict/>
    <key>CFBundleIcons~ipad</key>
    <dict/>
    <key>CFBundleIdentifier</key>
    <string>com.myproject.names</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>1.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.1</string>
    <key>CFBundleSignature</key>
    <string>myproject</string>
    <key>CFBundleVersion</key>
    <string>1.1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>UIMainStoryboardFile</key>
    <string>Main_iPhone</string>
    <key>UIMainStoryboardFile~ipad</key>
    <string>Main_iPad</string>
    <key>UIRequiresFullScreen</key>
    <string>YES</string>
    <key>UIStatusBarHidden</key>
    <false/>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleLightContent</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>appanalytics.embarcadero.com</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key><true/>
            </dict>
        </dict>
    </dict>
</dict>
</plist>

私もこれに基づいてフォローしてみました 質問

<dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>mydomain.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>

更新

here に記載されているコードを追加しましたが、それでも同じ問題が発生します。

更新

提案されたように、私はplistをfollowingに変更しましたが、それでも同じ問題があります。また、キータグの値にhttp://を追加しましたが無駄になりました。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.Apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleDisplayName</key>
    <string>My Project</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict/>
    <key>CFBundleIcons~ipad</key>
    <dict/>
    <key>CFBundleIdentifier</key>
    <string>com.myproject.names</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>1.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>3.1.6</string>
    <key>CFBundleSignature</key>
    <string>myproject</string>
    <key>CFBundleVersion</key>
    <string>1.2</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIMainStoryboardFile</key>
    <string>Main_iPhone</string>
    <key>UIMainStoryboardFile~ipad</key>
    <string>Main_iPad</string>
    <key>UIRequiresFullScreen</key>
    <string>YES</string>
    <key>UIStatusBarHidden</key>
    <false/>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleLightContent</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>myproject.com.ca</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
            <key>myproject.com.ca</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>
</dict>
</plist>
14
Jack

まず、Info.plistには2つの別々のNSAppTransportSecurityキーと値のペアがあります。ペアが1つだけになるように修正する必要があります。

あなたの質問は、あなたの画像がどのドメインからロードされているかについては述べていません。この情報を含めることができれば、具体的な回答を与える方が簡単です。

たとえば、画像がexample.comまたはサブドメインから読み込まれる場合、次のように例外を追加できます。

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>appanalytics.embarcadero.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
        <key>example.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

画像の読み込み元のドメインが事前にわからない場合は、代わりにすべてのドメインへのHTTPアクセスを許可できます。

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>appanalytics.embarcadero.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

この2番目の例にappanalytics.embarcadero.comを含めることは技術的に冗長ですが、アプリがアクセスするすべての既知のドメインに対してATS例外を指定することをお勧めします。

16
adurdin

構成方法についてこのチュートリアルを読むことができます App Transport Security または、情報に値「YES」を指定した「NSAllowsArbitraryLoads」という名前のブールキーを持つ辞書「NSAppTransportSecurity」を追加することで、以前と同じようにすべてを許可できます。 .plist。

1
Gillsoft AB

キー名はNSExceptionAllowsInsecureHTTPLoadsですが、NSTemporaryExceptionAllowsInsecureHTTPLoadsである必要があります

また、追加しようとしましたか

<key>NSExceptionRequiresForwardSecrecy</key>
<false/>

aTSドメインのキーに?
一部のドメインではそれが必要です。

1
blld