HamGuy
HamGuy

Reputation: 916

how to enable SSL connections in alamofire

how to enable ssl connections just as the AFNetworking did:

self.manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:kHostName]]; 
self.manager.securityPolicy.allowInvalidCertificates = YES;

I had neither username nor password in my case, just a post request like this

https://domain/request

and the parameter:

[email protected]

UPDATED

I had solved this case since I changed the parameter encoding form .JSON to .URL.

Upvotes: 1

Views: 5791

Answers (1)

marius bardan
marius bardan

Reputation: 5122

What about :

let user = "user"
let password = "password"

Alamofire.request(.GET, "https://httpbin.org/basic-auth/\(user)/\(password)")
         .authenticate(user: user, password: password)
         .response {(request, response, _, error) in
             println(response)
         }

From https://github.com/Alamofire/Alamofire.

Invalid HTTPS certificates feature does not seem to be available yet - https://github.com/Alamofire/Alamofire/issues/116 .

Upvotes: 2

Related Questions