Xamarin.iOS on Visual Studio 2017 requires the use of a secure connection

I am new in developing iOS using Xamarin on Visual Studio. I play around with new Cross Platform project and try to connect to Web API but received below error:

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

Anyone have the same issue?

Answers

  • prashantvcprashantvc USXamarin Team Xamurai

    Apple requires all network requests should be made over secure connection, but you can disable this in the app.

    Please follow these steps

    1. Open Project's info.plist file
    2. Add a Key called NSAppTransportSecurity as a Dictionary.
    3. Add a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.

    enter image description here

    Clean the Project and and rebuild

    Ref Link: https://stackoverflow.com/a/32609970

    OR In source code of info.plist file add NSAppTransportSecurity:

    <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
            <key>NSExceptionDomains</key>
            <dict>
                <key>yourdomain.com</key>
                <dict>
                    <key>NSIncludesSubdomains</key>
                    <true/>
                    <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                    <false/>
                </dict>
           </dict>
      </dict>
    
  • AgusSalimMokhtarAgusSalimMokhtar USMember
    edited July 2017

    I still can't make it works. I am developing using Visual Studio 2017 running on Windows. Below is the content of info.plist

    <?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">


    CFBundleDisplayName
    Storivo.Mobile.iOS
    CFBundleName
    Storivo.Mobile.iOS
    CFBundleIdentifier
    com.companyname.Storivo.Mobile
    CFBundleShortVersionString
    1.0
    CFBundleVersion
    1.0
    LSRequiresIPhoneOS

    MinimumOSVersion
    8.0
    UIDeviceFamily

    1
    2

    UILaunchStoryboardName
    LaunchScreen
    UIRequiredDeviceCapabilities

    armv7

    UISupportedInterfaceOrientations

    UIInterfaceOrientationPortrait
    UIInterfaceOrientationLandscapeLeft
    UIInterfaceOrientationLandscapeRight

    UISupportedInterfaceOrientations~ipad

    UIInterfaceOrientationPortrait
    UIInterfaceOrientationPortraitUpsideDown
    UIInterfaceOrientationLandscapeLeft
    UIInterfaceOrientationLandscapeRight


    NSAppTransportSecurity

    NSAllowsArbitraryLoads

    NSExceptionDomains

    localhost

    NSIncludesSubdomains

    NSThirdPartyExceptionRequiresForwardSecrecy




  • I still can't make it works. I am developing using Visual Studio 2017 running on Windows. Below is the content of info.plist:

  • PierceBogganPierceBoggan USForum Administrator, Xamarin Team, Developer Group Leader Xamurai

    Moving this to iOS for more visibility as it is an iOS issue.

  • AmirImamAmirImam USMember ✭✭

    @prashantvc said:
    Apple requires all network requests should be made over secure connection, but you can disable this in the app.

    Please follow these steps

    1. Open Project's info.plist file
    2. Add a Key called NSAppTransportSecurity as a Dictionary.
    3. Add a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.

    [![enter image description here][1]][1]

    Clean the Project and and rebuild

    Ref Link: [https://stackoverflow.com/a/32609970][2]

    OR In source code of info.plist file add NSAppTransportSecurity:

    <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
            <key>NSExceptionDomains</key>
            <dict>
                <key>yourdomain.com</key>
                <dict>
                    <key>NSIncludesSubdomains</key>
                    <true/>
                    <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                    <false/>
                </dict>
           </dict>
      </dict>
    

    [1]: http://i.stack.imgur.com/SZi2V.png
    [2]: https://stackoverflow.com/a/32609970

    Hi
    I am sorry if the topic is old but I am facing the same issue now, and I did your solution but still the same. How can I fix it

Sign In or Register to comment.