Cat load images on iOS app from s3 amazon

Hello, i am testing my applicatio on iphone and i want to get some images from amazon s3 server , but when i run my app on ios i get these errors: Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made. , but when i test it on browser everything seems to work ok !
any suggestion ?

I ran into this issue and what you need to do is fix your app’s transport security settings for iOS.

You can edit this in your plist file which is located under platforms > ios > YOUR APP > YOUR_APP.info.plist

I can post an example of mine if you get stuck. Also, don’t disable Transport Security for all domains, this is likely to get your app rejected from the App store. Instead you should disable specific domains, such as your s3 bucket.

Cheers

Hi @DaDanny,

Here is my plist file but I still get this error. I have a WCF service on my locak IIS when I try to call it, I am getting the “Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made.” error. By the way, I created a self signed certificate on IIS.(When I try to access https://192.168.1.23/wcf/OCRService.svc, It asks me to choose a certificate but there is only e-sign certificate, no self signed one.)

<?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>${PRODUCT_NAME}</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIconFile</key>
    <string>icon.png</string>
    <key>CFBundleIcons</key>
    <dict>
      <key>CFBundlePrimaryIcon</key>
      <dict>
        <key>CFBundleIconFiles</key>
        <array>
          <string>icon-40</string>
          <string>icon-small</string>
          <string>icon-60</string>
          <string>icon.png</string>
          <string>icon@2x</string>
          <string>icon-72</string>
          <string>icon-72@2x</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <false/>
      </dict>
    </dict>
    <key>CFBundleIcons~ipad</key>
    <dict>
      <key>CFBundlePrimaryIcon</key>
      <dict>
        <key>CFBundleIconFiles</key>
        <array>
          <string>icon-small</string>
          <string>icon-40</string>
          <string>icon-50</string>
          <string>icon-76</string>
          <string>icon-60</string>
          <string>icon</string>
          <string>icon@2x</string>
          <string>icon-72</string>
          <string>icon-72@2x</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <false/>
      </dict>
    </dict>
    <key>CFBundleIdentifier</key>
    <string>tr.com.fake.ios.lotto</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.0.0</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSMainNibFile</key>
    <string></string>
    <key>NSMainNibFile~ipad</key>
    <string></string>
    <key>UILaunchImages</key>
    <array>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default</string>
        <key>UILaunchImageOrientation</key>
        <string>Portrait</string>
        <key>UILaunchImageSize</key>
        <string>{320, 480}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default</string>
        <key>UILaunchImageOrientation</key>
        <string>Landscape</string>
        <key>UILaunchImageSize</key>
        <string>{320, 480}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-568h</string>
        <key>UILaunchImageOrientation</key>
        <string>Portrait</string>
        <key>UILaunchImageSize</key>
        <string>{320, 568}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-568h</string>
        <key>UILaunchImageOrientation</key>
        <string>Landscape</string>
        <key>UILaunchImageSize</key>
        <string>{320, 568}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-667h</string>
        <key>UILaunchImageOrientation</key>
        <string>Portrait</string>
        <key>UILaunchImageSize</key>
        <string>{375, 667}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-667h</string>
        <key>UILaunchImageOrientation</key>
        <string>Landscape</string>
        <key>UILaunchImageSize</key>
        <string>{375, 667}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-736h</string>
        <key>UILaunchImageOrientation</key>
        <string>Portrait</string>
        <key>UILaunchImageSize</key>
        <string>{414, 736}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-Landscape-736h</string>
        <key>UILaunchImageOrientation</key>
        <string>Landscape</string>
        <key>UILaunchImageSize</key>
        <string>{414, 736}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-Portrait</string>
        <key>UILaunchImageOrientation</key>
        <string>Portrait</string>
        <key>UILaunchImageSize</key>
        <string>{768, 1024}</string>
      </dict>
      <dict>
        <key>UILaunchImageMinimumOSVersion</key>
        <string>8.0</string>
        <key>UILaunchImageName</key>
        <string>Default-Landscape</string>
        <key>UILaunchImageOrientation</key>
        <string>Landscape</string>
        <key>UILaunchImageSize</key>
        <string>{768, 1024}</string>
      </dict>
    </array>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string></string>
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>
  </dict>
</plist>

Hmmm… honestly I’ve never even heard of WCF or local IIS before this post, so I can’t help you out with that.

If you need help retrieving images from S3, here is what I have in my plist. I have one for s3, then I have another one for each bucket, as well as my cloudfront sites. I only included one bucket in this example but they all look the same, just change the URL.

<key>NSAppTransportSecurity</key>
    <dict>
      <key>NSExceptionDomains</key>
      <dict>
        <key>s3.amazonaws.com</key>
        <dict>
          <key>NSExceptionRequiresForwardSecrecy</key>
          <false/>
        </dict>
        <key>{{MYBUCKET}}.s3.amazonaws.com</key>
        <dict>
          <key>NSIncludesSubdomains</key>
          <true/>
          <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
          <true/>
          <key>NSTemporaryExceptionMinimumTLSVersion</key>
          <string>TLSv1.1</string>
        </dict>
      </dict>
    </dict>

I’m not entirely sure if this is what you need since it sounds like you are doing some things differently. But I hope this helps.

Hi @DaDanny,

What does MYBUCKET mean?

I meant it to be a placeholder for my s3 bucket name. So if my bucket was ionicpics it would be

ionictips.s3.amazonaws.com

I hope this will stop my pain :smile:

<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>https://192.168.1.23/wcf/OCRService.svc</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>

Now I am getting this error

Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made

This solve my problem :

i had to paste the following code into appname-info.plist

<key>NSAppTransportSecurity</key>
NSAllowsArbitraryLoads

Thanks for answers !