nsurlcredential

深入理解HTTPS及在iOS系统中适配HTTPS类型网络请求(下)

时光怂恿深爱的人放手 提交于 2020-03-02 10:00:31
深入理解HTTPS及在iOS系统中适配HTTPS类型网络请求(下) 一、引言 上一篇博客详细讨论了HTTPS协议的原理,搭建HTTPS测试环境以及证书的相关基础。本篇博客将继续探讨更多在iOS开发中适配HTTPS类型请求的内容。上篇博客的地址如下: https://my.oschina.net/u/2340880/blog/807358 。 二、关于NSURLAuthenticationChallenge相关类 我们在实现URLSession的认证协议方法时,会接收到一个NSURLAuthenticationChallenge类型的参数。简单理解,这个参数就是服务端发起的一个验证挑战,客户端需要根据挑战的类型提供相应的挑战凭证。当然,挑战凭证不一定都是进行HTTPS证书的信任,也可能是需要客户端提供用户密码或者提供双向验证时的客户端证书。当这个挑战凭证被验证通过时,请求便可以继续顺利进行。NSURLAuthenticationChallenge类对象中有一个sender代理实例,开发者通过这个实例来可控采用怎样的验证方式。解析如下: //使用凭证进行验证 - (void)useCredential:(NSURLCredential *)credential forAuthenticationChallenge:(NSURLAuthenticationChallenge *

Stream large movie with credential through MPMoviePlayer

ε祈祈猫儿з 提交于 2020-01-04 06:29:06
问题 I've been trying to stream a movie from a url that is protected. I can download the movie then play it, but the movie is too long so this is annoying. Here is my code: -(MPMoviePlayerController *)moviePlayerController { NSURL *url = [NSURL URLWithString:@"http://ABcDE.com/secret/Movie.mov"]; _moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; NSURLCredential *credential = [[NSURLCredential alloc] initWithUser: @"user" password: @"password" persistence:

Stream large movie with credential through MPMoviePlayer

我的未来我决定 提交于 2020-01-04 06:28:21
问题 I've been trying to stream a movie from a url that is protected. I can download the movie then play it, but the movie is too long so this is annoying. Here is my code: -(MPMoviePlayerController *)moviePlayerController { NSURL *url = [NSURL URLWithString:@"http://ABcDE.com/secret/Movie.mov"]; _moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; NSURLCredential *credential = [[NSURLCredential alloc] initWithUser: @"user" password: @"password" persistence:

NSURLCredential and NSURLConnection

自作多情 提交于 2020-01-01 06:25:27
问题 I have been trying to search for a way to unset the credentials once you set a NSURLCredential with a NSURLConnection that is using NSURLCredentialPersistenceForSession, but I couldn't find a working solution. Removing the NSURLCredential from the NSURLCredentialStorage only removes it from the storage and not from the NSURLConnection cache. I tried turning cache off and it still keeps it. I need it to be NSURLCredentialPersistenceForSession as I don't want it to be uploading the large data

How to get cookie from Webserver and maintain it in iOS app?

怎甘沉沦 提交于 2019-12-25 03:27:10
问题 I would like to to get fetch JSON from http://mycompany.com/page1...http://mycompany.com/page2... On the the webserver side, it requires initial login http://mycompany.com/login, and after that a cookie is maintained for the user. How do I get this behavior with NSURLConnection without having to ask for login every time? Here is the non-working code using NSURLCredential Storage. Do I need to get the cookie from webservice at loging and then send it along with later requests? I struggled with

iOS: Playing video that needs authentication works in QuickLook but not in MPMoviePlayerViewController

自古美人都是妖i 提交于 2019-12-22 04:35:53
问题 I login to my server using a SOAP web service . Once logged in, many of the files that I am viewing are only available to the logged in user, so iOS must create a session in NSURL or something. When trying to preview a video file using MPMoviePlayerViewController it will not work, it just loads up the viewController, then dismisses it. If I use QuickLook it does work, probably because I download the video locally first, then view it. But, I don't want to do it this way, I want to stream the

NSURLConnection does not use the default credential

ぐ巨炮叔叔 提交于 2019-12-21 05:16:10
问题 I'm trying to connect to http://cmis.demo.nuxeo.org/nuxeo/atom/cmis/ with NSURLConnection . This demo web service is documented to require authentication (login: Administrator / password: Administrator). Edit : This web service now sends an authentication challenge, it was not at the time the question was asked. This web service does not send an authentication challenge, so I can't use the connection:didReceiveAuthenticationChallenge: delegate method. Instead I set a default NSURLCredential

NSURLCredentialStorage and client certificate authentication

浪尽此生 提交于 2019-12-18 13:48:25
问题 From what I see in the documentation of MPMoviewPlayerController, NSURLCredentialStorage can be set up as an alternative of NSURLConnection authentication challenges (this is useful for higher level classes that load resources from URLs but abstract the NSURLConnection away and don't provide a delegate for handling authentication challenges). This seems similar to installing a certificate in the browser and having it auto select the required certificate when a certain address demands it. To

NSURLConnection, NSURLRequest, untrusted cert and user authentication

北慕城南 提交于 2019-12-09 03:06:40
问题 Morning Everyone, I've been attempting to write an application that does some GETs from a remote Web Service that requires authentication. My main problem is that the majority of these remote servers (and there are a lot of them) don't have valid certificates. I've got code to accept the invalid certificate and code to respond to the challenge with the correct uname & pass (below). The problem I'm having is getting the two to play together. I can't seem to find a way to send the challenge

Clear the credentials from UIWebView

佐手、 提交于 2019-12-06 03:49:57
问题 What i am doing here is, fetching a URL which has authentication. Hence, i use the function - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge; When it faces authentication, i present a UIAlertView to enter the username and password and if user has entered it correctly, this method is called. - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response; in this method, i make the login