Can't make HTTPS requests to local server

Viewed 683

I have a local server running on Laravel Homestead:

https://laravel.com/docs/5.3/homestead

Homestead comes pre-packaged with an SSL certificate and I make all my requests through HTTPS. However, when trying to make a request from my iOS app, I get the following error:

ATS failed system trust
Connection 3: system TLS Trust evaluation failed(-9802)
Connection 3: TLS Trust encountered error 3:-9802
Connection 3: encountered error(3:-9802)
Task <892C4896-1D02-4465-AF06-D7534BE39828>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9802])
Task <892C4896-1D02-4465-AF06-D7534BE39828>.<1> finished with error [-1200] Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
    "<cert(0x7fc76e82d800) s: mydomain.test i: Homestead homestead Root CA>"
)

I've added the following to my Info.plist:

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsLocalNetworking</key>
        <true/>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>

After reading some articles and Github issues on SSL pinning through Alamofire and Moya, I've also done the following:

let evaluators: [String: ServerTrustEvaluating] = [
    "mydomain.test": DisabledEvaluator()
]

let manager = ServerTrustManager(evaluators: evaluators)
let session = Session(serverTrustManager: manager)

let provider = MoyaProvider<T>(session: session, plugins: [NetworkLoggerPlugin(verbose: true)])

I also installed the certificate on my Mac and set it to "Always Trust", but I still get the error when I run my iOS app.

What am I doing wrong? What am I missing?

1 Answers

This is my solution, maybe not complete your question. I don't use url as "myweb.local". I used direct IP and change port for app in developement. When you use port, you will not need to SSL. Example:

127.0.0.1:8000

Related