1. Obtaining a Certificate
</ Dev/null 2 > /dev/null | OpenSSL x509-outform DER > Https.cer "in the colon is the main part of the command. This command will form the public binary certificate of the google.com site, named Https.cer, under the current path. You can replace www.google.com with your own site to get the https.cer of your own site.
2. Certificates added to the project
3. The code used
Afsecuritypolicy *securitypolicy = [[Afsecuritypolicy alloc] init]; [SecurityPolicy Setallowinvalidcertificates:no]; [SecurityPolicy setsslpinningmode:afsslpinningmodecertificate]; [SecurityPolicy Setvalidatesdomainname:yes]; [SecurityPolicy Setvalidatescertificatechain:no]; Manager.securitypolicy = securitypolicy;
Settings for 4.mode
typedef ns_enum (Nsuinteger, Afsslpinningmode) { afsslpinningmodenone, Afsslpinningmodepublickey, Afsslpinningmodecertificate,};
IOS Development Network Detailed (eight)---afsecuritypolicy