신뢰할 수없는 SSL 인증서로 신속하게 HTTPS 사이트에 로그인하는 데 어려움을 겪고 있습니다. NSURLConnectionDelegate 메서드를 사용하여 내 UIWebView 안에 페이지를 볼 수 있습니다. 웹 브라우저를 사용하여이 웹 사이트에 자동 로그인 할 수 있습니다 (예 : URL - https://mywebsite.com:8003/home.html?session_id=sessionVariable).신뢰할 수없는 SSL 인증서가있는 HTTPS 사이트의 자동 로그인 문제가 신속하게
내 대리인 기능은let websiteURL = "https://mywebsite.com:8003/home.html?session_id=\(Session_Id)"
print(websiteURL)
let url = NSURL (string: websiteURL)
let urlRequest = NSURLRequest(URL: url!)
let urlConnection:NSURLConnection = NSURLConnection(request: urlRequest, delegate: self)!
self.webviewInstance.loadRequest(urlRequest)
func connection(connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: NSURLProtectionSpace) -> Bool{
print("canAuthenticateAgainstProtectionSpace method Returning True")
return true
}
func connection(connection: NSURLConnection, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge){
print("did autherntcationchallenge = \(challenge.protectionSpace.authenticationMethod)")
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
print("send credential Server Trust")
let credential = NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!)
challenge.sender!.useCredential(credential, forAuthenticationChallenge: challenge)
}else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodHTTPBasic{
print("send credential HTTP Basic")
let defaultCredentials: NSURLCredential = NSURLCredential(user: "username", password: "password", persistence:NSURLCredentialPersistence.ForSession)
challenge.sender!.useCredential(defaultCredentials, forAuthenticationChallenge: challenge)
}else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodNTLM{
print("send credential NTLM")
} else{
challenge.sender!.performDefaultHandlingForAuthenticationChallenge!(challenge)
}
}
내가 키 NSAppTransportSecurity 내 PLIST 파일의 변화를 aded 한 NSAllowsArbitraryLoads 등 :하지만있는 UIWebView에서
다음가있는 viewDidLoad 안에 내 코드입니다
이 서버와 JSON 호출을 상호 작용할 수 있습니다. 그러나 webView에서 자동 로그인이 작동하지 않습니다. 상담하십시오.