3
votes

I can't get Charles to work with Alamofire, I always get:

SSLHandshake: Remote host closed connection during handshake You may need to configure your browser or application to trust the Charles Root Certificate. See SSL Proxying in the Help menu.

I did install the Charles root certificate in iOS Simulator and added the host to connect to to the SSL proxying settings. Do you have any further suggestions? Thanks a lot!

3

3 Answers

4
votes

On iOS11 I missed this additional step.

In the Settings app,

Navigate to General.About.Certificate settings.

Enable the Charles Proxy SSL Proxying switch.

3
votes

This is probably due to the addition of App Transport Security in iOS 9. To allow Charles access to the SLL traffic you need to add the following to your app's Info.plist:

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

(from Charles' FAQ on the subject)

Note: You probably only want to do this for debugging purposes, and not ship your app with ATS essentially disabled.

2
votes

In addition to the NSAppTransportSecurity that Thor describes, you also have to trust the certificate. If you go to Charles' "Help" menu, you will see a "SSL Proxy" submenu. When I selected "Install Charles Root Certificate" and "Install Charles Root Certificate in iOS Simulators" from that sub menu, I was then able to successfully proxy https requests. Obviously, I also added the host in question to the "Proxy" - "SSL Proxy Settings" (e.g. with a port of * and the full hostname).