Certificate SwiftHTTP凭据和自签名证书
我正在使用SwiftHTTP并尝试从我的服务器获取JSON提要。服务器具有自签名证书,并可通过用户和密码进行访问 我试着用阿拉莫菲尔,但没有找到解决办法 这是我的密码Certificate SwiftHTTP凭据和自签名证书,certificate,credentials,trust,Certificate,Credentials,Trust,我正在使用SwiftHTTP并尝试从我的服务器获取JSON提要。服务器具有自签名证书,并可通过用户和密码进行访问 我试着用阿拉莫菲尔,但没有找到解决办法 这是我的密码 HTTP.globalRequest { req in req.timeoutInterval = 5 } //set a global SSL pinning setting HTTP.globalSecurity(HTTPSecurity()) //see the SSL sec
HTTP.globalRequest { req in
req.timeoutInterval = 5
}
//set a global SSL pinning setting
HTTP.globalSecurity(HTTPSecurity()) //see the SSL section for more info
//set global auth handler. See the Auth section for more info
HTTP.globalAuth { challenge in
return URLCredential(user: "user", password: "passwd", persistence: .forSession)
}
do {
let opt = try HTTP.GET("https://10.0.1.2:4711/fhem/?cmd=jsonlist2&XHR=1",requestSerializer: JSONParameterSerializer())
//the auth closures will continually be called until a successful auth or rejection
var attempted = false
opt.auth = { challenge in
if !attempted {
attempted = true
return URLCredential(forTrust: challenge.proposedCredential?.certificates)
}
return nil
}
opt.start { response in
print("success")
print("opt finished: \(response.data)")
}
} catch let error {
print("got an error creating the request: \(error)")
}
}
有人有主意吗