0

I have to make a POST request in my app and I have a esb.dummy.com.crt certificate. I need the certificate access the server.

let request = NSMutableURLRequest(URL: NSURL(string: "https://esb.dummy.com/Common/MyPing?wsdl")!)
request.HTTPMethod = "POST"
request.timeoutInterval = 90
request.setValue("Basic XYZ", forHTTPHeaderField: "Authorization")
request.HTTPBody = getPingBody()
NSURLSession.sharedSession().dataTaskWithRequest(request){...}.resume()

How can I add the certificate to the app or something to make the request?

yasin
  • 1,297
  • 3
  • 17
  • 36
  • Did you try: http://stackoverflow.com/questions/32525736/handling-app-transport-security-kcfstreamerrordomainssl-9802/32525737#32525737 – Daniel Sumara Aug 10 '16 at 13:54
  • @DanielSumara yes, but it didn't work. If if decrease security of a specific URL or turn off the security, I get the error "An SSL error has occurred and a secure connection to the server cannot be made." – yasin Aug 10 '16 at 14:22

1 Answers1

1

Do what mentioned before Handling App Transport Security (kCFStreamErrorDomainSSL, -9802)

But add NSTemporaryExceptionAllowsInsecureHTTPLoads and NSTemporaryExceptionMinimumTLSVersion keys also.

Example:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>yourserver.com</key>
      <dict>
        <!--Include to allow subdomains-->
        <key>NSIncludesSubdomains</key>
        <true/>
        <!--Include to allow HTTP requests-->
        <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <!--Include to specify minimum TLS version-->
        <key>NSTemporaryExceptionMinimumTLSVersion</key>
        <string>TLSv1.1</string>
      </dict>
  </dict>
</dict>
Community
  • 1
  • 1
  • I get the error "NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." " I also call the server for http requests where I get the error "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" if I turn off the security – yasin Aug 10 '16 at 16:09