Read the article first, this article is about using afnetworing for HTTPS when things, very good! http://blog.cnbang.net/tech/2416/
Using HTTPS in iOS is primarily the use of nsurlcredential, first look at the necessary official documents:
nsurlcredential is an immutable object representing an authentication credential consisting of authentication information specific to the type of credent Ial and the type of persistent storage to use, if the URL Loading system supports three types of Credentials:password -based user credentials, certificate-based user credentials, and certificate- Span style= "color: #000000;" >based server credentials (used when verifying the server's identity). When you create a credential, you can specify the it should be used for a Sin GLE request, persisted temporarily (until your app quits), or persisted permanently (in the keychain).
Although there are many kinds of credentials, there are only 3 of them for URLs!
So there are 3 initialization methods:
+ Credentialfortrust:+ credentialWithUser:password:persistence:+ credentialwithidentity: Certificates:persistence:
Also, refer to the authentication section in the URL Session Programming Guide:
To attempt to authenticate, the application should create a Nsurlcredential object with authentication information of the Form expected by the server. You can determine the server's authentication method by calling Authenticationmethod on the protection space of the Provid Ed authentication challenge. Some authentication methods supported by Nsurlcredential Are:http Basic Authentication ( Nsurlauthenticationmethodhttpbasic) requires a user name and password. Prompt the user for the necessary information and create a Nsurlcredential object with CredentialWithUser:password:persis Tence:.
HTTP Digest Authentication (nsurlauthenticationmethodhttpdigest), like Basic authentication, requires a user name and pass Word. (The digest is generated automatically.) Prompt the user for the necessary information and create a Nsurlcredential object with CredentialWithUser:password:persis Tence:.
Client certificate Authentication(nsurlauthenticationmethodclientcertificate) requires the system identity and all certificates needed to authenticate wit H the server. Create an Nsurlcredential object with CredentialWithIdentity:certificates:persistence:.
Server Trust Authentication(Nsurlauthenticationmethodservertrust) requires a trust provided by the protection space of the authentication challenge. Create an Nsurlcredential object with Credentialfortrust:. After you ' ve created the Nsurlcredential object:For nsurlsession, pass the object to the authentication challenge ' s sender using the provided completion handler block.For Nsurlconnection and Nsurldownload, pass the object to the authentication Challenge's sender with Usecredential:forauthenticationchallenge:.
Knowledge of using HTTPS in iOS