+ (afsecuritypolicy*) customsecuritypolicy{///import Certificates FirstNSString *cerpath = [[NSBundle mainbundle] Pathforresource:@"Kudou"OfType:@"cer"];//path to the certificateNSData *certdata =[NSData Datawithcontentsoffile:cerpath]; //afsslpinningmodecertificate Using certificate validation modeAfsecuritypolicy *securitypolicy =[Afsecuritypolicy policywithpinningmode:afsslpinningmodecertificate]; //allowinvalidcertificates whether to allow invalid certificates (that is, self-built certificates), default to No//If you need to validate your self-built certificate, you need to set it to YesSecuritypolicy.allowinvalidcertificates =YES; //Validatesdomainname If you need to verify the domain name, the default is yes;//if the domain name of the certificate does not match the domain name you requested, you need to set the entry to no, and if it is set to No, the server can also establish a connection by using a certificate issued by another trusted authority, which is very dangerous and is recommended to be opened. //set to No, mainly used in this case: the client is requesting a subdomain, and the certificate is a different domain name. Because the domain name on the SSL certificate is independent, if the domain name registered on the certificate is www.google.com, then mail.google.com cannot be verified; Of course, the rich can register the wildcard name *.google.com, but this is still relatively expensive. //if set to No, it is recommended that you add the check logic for the corresponding domain name. Securitypolicy.validatesdomainname =NO; //[Nsset Setwithobject:certdata]//@[certdata]Securitypolicy.pinnedcertificates =@[certdata]; returnsecuritypolicy;}
This invokes the---
+ (afhttpsessionmanager *) Getafhttprequestoperationmanager
{
MYLog(@ "1.getAFHTTPRequestOperationManager");
[Self getToken];
afhttpsessionmanager *manager = [afhttpsessionmanager manager];
Manager. Responseserializer = [afjsonresponseserializer serializer];
Manager.requestserializer=[afjsonrequestserializer Serializer];
Manager. Responseserializer. Acceptablecontenttypes = [nsset setwithobjects:@ "Application/json",@ "Text/json" , @ "text/plain", @ "text/javascript",@ "text/html", Nil];
Manager. Requestserializer. timeOutInterval = 60.f;
[Manager Setsecuritypolicy: [self customsecuritypolicy]];
return manager;
}
Afnetworking Certificate afnetworking Certificate settings