![](/img/trans.png)
[英]Why would IOS SSL handshake fail with a trusted certificate at the other end
[英]Cant get past SSL handShake on iOS simulator even after manual installing certificate
簡介:努力在我的iOS模擬器上通過SSL握手。
我試圖通過我的iOS模擬器Xcode 7.2模擬器9.2上的SSL握手。 我已經從應用程序網頁(URL)中提取了.cer文件,並手動將其安裝在模擬器中,但沒有設法克服模擬器中的SSL握手。
背景資料:
我嘗試過的。 (均在使用公司WIFI時嘗試過)
我們歡迎所有的建議
路加
我遇到了一個類似的問題,使我的應用程序可以使用我的SSL證書,並通過以下方式解決了該問題:
將.cer文件包含到xcode的apps目錄中。
使用Alamofire和以下代碼進行固定並完成SSL握手
let hatchliCert = "nameOfCert"
var urlSession: NSURLSession!
var serverTrustPolicy: ServerTrustPolicy!
var serverTrustPolicies: [String: ServerTrustPolicy]!
var afManager: Manager!
func configureAlamoFireSSLPinningWithCertificateData(certificateData: NSData) {
print("entering alamo ssl pinning")
let pathToCert = NSBundle.mainBundle().pathForResource(hatchliCert, ofType: "cer")
let localCertificate:NSData = NSData(contentsOfFile: pathToCert!)!
self.configureAlamoFireSSLPinningWithCertificateData(localCertificate)
self.serverTrustPolicy = ServerTrustPolicy.PinCertificates(
// Getting the certificate from the certificate data
certificates: [SecCertificateCreateWithData(nil, certificateData)!],
// Choose to validate the complete certificate chain, not only the certificate itself
validateCertificateChain: true,
// Check that the certificate matches the host who provided it
validateHost: true
)
self.serverTrustPolicies = ["www.nameOfWebsite.com": self.serverTrustPolicy!]
self.afManager = Manager(
configuration: NSURLSessionConfiguration.defaultSessionConfiguration(),
serverTrustPolicyManager: ServerTrustPolicyManager(policies: self.serverTrustPolicies)
)
}
這對我有用,但看來您在公司安全方面的情況略有不同。 希望能幫助到你!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.