Quick Summary
The error "NSURLErrorDomain -1012" on an iPhone indicates a failure to establish a secure connection with the server, typically due to issues with the SSL/TLS certificate or the way the iOS device trusts the server. It implies a problem verifying the server's identity, leading to the connection being refused for security reasons.
Common Causes
- Untrusted or Invalid SSL Certificate: The server's SSL certificate might be self-signed, expired, revoked, or issued by an untrusted Certificate Authority (CA). iOS requires valid certificates from trusted CAs to ensure secure communication. If the certificate is invalid, the connection fails.
- Certificate Pinning Issues: If the app implements certificate pinning (hardcoding the expected certificate), a mismatch between the pinned certificate and the server's current certificate will cause this error. Even if the certificate is generally valid, the pinning mechanism can reject it if it doesn't precisely match the expected one.
- Network Configuration Problems: Incorrect date and time settings on the iPhone can cause SSL certificate validation to fail, as certificates are only valid within specific date ranges. Similarly, network proxies or VPNs may interfere with the SSL handshake process, leading to certificate verification errors.
- App Transport Security (ATS) Restrictions: ATS enforces secure connections on iOS, mandating HTTPS and certain cipher suites. If the server doesn't meet Apple's ATS requirements, the connection may be blocked. While ATS exceptions can be configured, improper configuration of these exceptions can also lead to this error.
Step-by-Step Fixes
Method 1: Verify Date and Time Settings
Step 1: Open the Settings app on your iPhone.
Step 2: Navigate to General > Date & Time.
Step 3: Ensure that Set Automatically is enabled. If it's already enabled, toggle it off and on again to refresh the date and time.
Step 4: Verify that the displayed date and time are correct.
Method 2: Check Network Connectivity and Proxy Settings
Step 1: Ensure you have a stable internet connection (Wi-Fi or cellular data).
Step 2: In Settings, go to Wi-Fi and select your Wi-Fi network. Verify there are no proxy settings configured.
Step 3: If you're using a VPN, temporarily disable it to see if it resolves the issue. Sometimes VPN configurations can interfere with secure connections.
Step 4: If you're using cellular data, make sure the app has permission to use it in Settings > Cellular.
Method 3: Trust the Certificate (If Self-Signed - Proceed with Caution!)
Note: This method is only applicable if you are testing a development server with a self-signed certificate. It is strongly discouraged for production apps due to security risks.
Step 1: If you are accessing a website, navigate to that website in Safari. You will likely see a warning about the untrusted certificate.
Step 2: Choose to proceed to the website anyway. Details on permanent certificate trusting may vary according to iOS version.
Step 3: For apps, the developer usually needs to implement a specific workflow to allow exceptions for untrusted certificates. This is usually done during development and testing.
Method 4: Update iOS to the Latest Version
Step 1: Open the Settings app on your iPhone.
Step 2: Navigate to General > Software Update.
Step 3: If an update is available, download and install it. Newer versions of iOS may include improved handling of SSL certificates and ATS policies.
Method 5: Contact the App Developer/Website Administrator
Step 1: If the problem persists after trying the above solutions, the issue might be on the server-side or within the app's code.
Step 2: Contact the app developer or website administrator and provide them with details about the error, including the error code "NSURLErrorDomain -1012".
Step 3: They can investigate the server's SSL configuration, ATS settings, or certificate pinning implementation to identify and resolve the problem.