iOS Learning Journey (App Transport Security) issues related to HTTPS protocol requirements

Source: Internet
Author: User

Problem description

Write the following code to get the mimetype of a resource on the network

1-(void) GetMimeType2 {3     //Path4Nsurl *url = [Nsurl urlwithstring:@"Https://www.baidu.com/img/bd_logo1.png"];5     //Request Object6Nsmutableurlrequest *request =[Nsmutableurlrequest Requestwithurl:url];7Nsoperationqueue *queue =[[Nsoperationqueue alloc]init];8[Nsurlconnection sendasynchronousrequest:request queue:queue completionhandler:^ (NSURLResponse * _Nullable response, NSData * _nullable data, Nserror *_nullable Connectionerror) {9NSLog (@"%@", Response. MIMEType);Ten     }]; One}

The following error is prompted for the run:

Nsurlsession/nsurlconnection HTTP Load failed (Kcfstreamerrordomainssl,-9802), and The result of the request returned is nil

Problem resolution ATS Requirements

Because Apple introduced privacy protection in iOS9 ATS (App Transport Security) Shielded HTTP protocol, encountered HTTP-related issues during the learning process, so wrote this article iOS Learning Tour 7 ATS security feature masking HTTP protocol, But today we have a problem with ATS.

In apps compiled for iOS 9.0 and later versions and OS X10.11 and later versions, all connections using Nsurlconnection, Cfurl, or nsurlsession use the ATS default behavior. An ATS connection that does not comply with the following requirements will fail and be disconnected.

    • The server must support at least Transport Layer Security (TLS) protocol version 1.2.
    • The password for the connection is limited to a password that provides full forward secrecy (perfect forward secrecy). (See the password list below)
    • Certificates must be signed using the SHA256 hash algorithm or a better signature hashing algorithm, using a 2048-bit or higher RSA key, or a 256-bit or higher elliptic-curve (ECC) key. Otherwise, an invalid certificate will cause the connection to fail and disconnect.

The following is an acceptable password:
tls_ecdhe_ecdsa_with_aes_256_gcm_sha384
tls_ecdhe_ecdsa_with_aes_128_gcm_sha256
tls_ecdhe_ecdsa_with_aes_256_cbc_sha384
Tls_ecdhe_ecdsa_with_aes_256_cbc_sha
tls_ecdhe_ecdsa_with_aes_128_cbc_sha256
Tls_ecdhe_ecdsa_with_aes_128_cbc_sha
tls_ecdhe_rsa_with_aes_256_gcm_sha384
tls_ecdhe_rsa_with_aes_128_gcm_sha256
tls_ecdhe_rsa_with_aes_256_cbc_sha384
tls_ecdhe_rsa_with_aes_128_cbc_sha256
Tls_ecdhe_rsa_with_aes_128_cbc_sha

Full forward secrecy (perfect forward secrecy)

Checked the information, fully positive secrecy (perfect forward secrecy) requires a key to access only the data protected by it, and cannot derive another key using the key that secures the data transfer. In addition, you cannot use the source of the key that secures the data transfer to derive other keys, and a key that is cracked does not affect the security of the other keys. Ensuring that the key's long-term confidential material does not affect the confidentiality of the exchanged key from the previous communication.

"TLS" naturally refers to the TLS protocol. "ECDHE" is the use of elliptic curves with ephemeral keys Diffie-hellman key exchange (that is, to create a new key for each session and not write it down afterwards). "RSA" indicates the security of TLS handshake protection with RSA asymmetric encryption. "AES_128_CBC" is to protect true data exchange with AES asymmetric encryption with 128-bit key in cipher block link mode. The last "Sha" indicates the use of the SHA Secure Hash algorithm.

Problem solving

iOS Learning Journey (App Transport Security) issues related to HTTPS protocol requirements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.