Search code examples
iosuiwebviewnsurlconnection

NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9843)


I'm now trying my app in testing environment, and the app have a feature that open a URL in a webview, but now testing, the files URL in production database come from Amazon and have this format:

self.url = @"https://media.akdemia.com.s3.amazonaws.com/production//uploads/report_notification/report/3827/Corte_de_Notas_de-QUINTO_A_O_DE_CIENCIAS_A.pdf?AWSAccessKeyId=AKIAI2R6DMWPFKJPDVWQ&Signature=wwq2kCTVsOlA/Sc/xIT108XF8/0%3D&Expires=1447112397" 

I can't open it by:

NSURL *myUrl = [NSURL URLWithString:self.url];
NSURLRequest *myRequest = [NSURLRequest requestWithURL:myUrl];

[self.webView loadRequest:myRequest];

Isn't a common url and the console print this error:

NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9843)

Extra info

In my app I have a reports list, and when it request to API the URL of each report, it generates a URLs list.

If I request that URLs from console is generate the same URL but distinct Expires numbers for each URL and all of this URL works correctly, while if I print the JSON that API returns for the app I can see that all the URLs (no matter which report belongs) have the same Expires number. I don't know if this can affect the URL and then it no works.


Solution

  • I resolved the issue, I'm using Ruby on Rails for API implementation, and I changed fog and carrierwave gem version to 1.9.0 and 0.10.0 on the Gemfile (you have to run bundle install to update).

    Using the same fog_credentials

    config.fog_credentials = {
          :provider               => 'AWS',       # required
          :aws_access_key_id      => 'AKIAI2R6DMWPFKJPDVWQ',       # required
          :aws_secret_access_key  => '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',       # required
    }
        config.fog_directory  = 'media.akdemia.com'                     # required
        config.fog_public     = false
        config.cache_dir = "#{Rails.root}/tmp/uploads"
        config.fog_authenticated_url_expiration = 1.year
        config.storage = :fog
    

    And then the API generates URLs correctly https://s3.amazonaws.com/media.akdemia.com/production/.... instead of https://media.akdemia.com.s3.amazonaws.com/production/....

    Thanks guys @Kampai and @pbasdf you were helpful to find the solution