【发布时间】:2016-07-28 16:52:55
【问题描述】:
我是一名新生,在我大一之后的暑期项目中工作,几乎没有经验,我遇到了错误
错误域=NSURLErrorDomain 代码=-1012 "(null)" UserInfo={NSErrorFailingURLKey=https://localhost/donate/payment.php, NSErrorFailingURLStringKey=https://localhost/donate/payment.php}
当我尝试通过条带进行信用卡支付时,我拥有的代码是
func postStripeToken(token: STPToken) {
let URL = "https://localhost/donate/payment.php"
let params : [String: AnyObject] = ["stripeToken": token.tokenId,
"amount": myInt,
"currency": "usd",
"description": self.emailTextField.text!]
let manager = AFHTTPRequestOperationManager()
manager.POST(URL, parameters: params, success: { (operation, responseObject) -> Void in
if let response = responseObject as? [String: String] {
UIAlertView(title: response["status"],
message: response["message"],
delegate: nil,
cancelButtonTitle: "OK").show()
}
}) { (operation, error) -> Void in
self.handleError(error!)
}
}
它想要一个 HTTP url 而不是 HTTPS,但是当我将它更改为 HTTP 并且当用户按下他们的卡付款时它不安全,他们会收到一个错误
资源无法加载海滩 APP 传输安全 政策要求使用安全连接。
有没有我可以使用 HTTPS 而不会收到 NSURL 错误,或者我可以在没有HTTPS 的情况下建立安全连接?任何提示都会非常有帮助!
manager.securityPolicy.allowInvalidCertificates = true;
我也尝试添加此语句,但没有成功。
【问题讨论】:
标签: debugging afnetworking nsurlconnection afnetworking-2 afnetworking-3