我知道此问题是先前被问过的!但是这些解决方案似乎都不适用于我。我通过网址播放音频文件时收到此错误。
注意:服务器已根据Apple ATS升级并使用https://。更新所有网络呼叫(AFNetworking 3.0)以使用并兼容iOS 9.没有解决方法在plist中处理异常(见下文)。
我必须从下面的代码片段播放视频/音频文件,这会抛出此错误。 NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
app如何播放视频/音频文件:
//This is https url:
self.movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:self.browserMediaItem.mediaItem.media_item_hd_url]];
self.movieController.movieSourceType = MPMovieSourceTypeFile;
[self.movieController prepareToPlay];
[self.movieController.view setFrame:_photoImageView.frame];
[self addSubview:self.movieController.view];
[self.movieController play];
如果我在plist中添加了<key>NSAllowsArbitraryLoads</key>
行,则会出现以下错误。
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9843)
这是我的.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">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>AppName</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>domain.com</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>73</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
<array>
<string>OpenSans-Italic.ttf</string>
<string>FontAwesome.ttf</string>
<string>OpenSans-Semibold.ttf</string>
<string>OpenSans-Bold.ttf</string>
<string>OpenSans-Regular.ttf</string>
<string>OpenSans-Light.ttf</string>
</array>
<key>UIMainStoryboardFile</key>
<string>Main_iPhone</string>
<key>UIMainStoryboardFile~ipad</key>
<string>Main_iPad</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarHidden</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackTranslucent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIViewEdgeAntialiasing</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
编辑:
curl -v your_url
的输出:
* Trying 40.146.243.53...
* Connected to t-mobi.name.school.nz (40.146.243.53) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.name.school.nz
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET /api/v2/users/bW9iaWxldGVzdA==/galleries/197/audios/27 HTTP/1.1
> Host: t-mobi.name.school.nz
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: -1
< Location: https://t.azure.name.school.nz//DataStore/Users/test/uSpace/Audio/mp3/0b27c797-5.mp3
< Server: Microsoft-IIS/8.5
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< Date: Mon, 22 Feb 2016 18:33:16 GMT
< Content-Length: 0
<
* Connection #0 to host t-mobi.name.school.nz left intact
输出:openssl s_client -connect your_host:your_port -showcerts
:(i.e. openssl s_client -connect t-mobi.name.school.nz:443 -showcerts)
CONNECTED(00000003)
709:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59/src/ssl/s23_clnt.c:593:
curl -vL url
的输出:
* Trying 40.146.243.53...
* Connected to t-mobi.name.school.nz (40.146.243.53) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.name.school.nz
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET /api/v2/users/bW9iaWxldGVzdA==/galleries/197/audios/27 HTTP/1.1
> Host: t-mobi.name.school.nz
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: -1
< Location: https://t.name.school.nz//DataStore/Users/mobiletest/uSpace/Audio/mp3/0b27c797-5.mp3
< Server: Microsoft-IIS/8.5
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< Date: Tue, 23 Feb 2016 03:50:12 GMT
< Content-Length: 0
<
* Connection #0 to host t-mobi.name.school.nz left intact
* Issue another request to this URL: 'https://t.name.school.nz//DataStore/Users/mobiletest/uSpace/Audio/mp3/0b27c797-5.mp3'
* Trying 40.146.243.53...
* Connected to t.name.school.nz (40.146.243.53) port 443 (#1)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate: *.name.school.nz
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET //DataStore/Users/mobiletest/uSpace/Audio/mp3/0b27c797-5.mp3 HTTP/1.1
> Host: t.name.school.nz
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: public,max-age=1209601
< Content-Type: audio/mpeg
< Last-Modified: Fri, 19 Feb 2016 02:22:53 GMT
< Accept-Ranges: bytes
< ETag: "fb7d26fbc6ad11:0"
< Server: Microsoft-IIS/8.5
< X-Powered-By: ASP.NET
< Date: Tue, 23 Feb 2016 03:50:16 GMT
< Content-Length: 2593081
<
ID36TIT2 1rack10TSSELavf55.14.101????Info
'??...
whereis openssl
的输出:
/usr/bin/openssl
openssl version
的输出:
OpenSSL 0.9.8zg 14 July 2015