Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Certificate SwiftHTTP凭据和自签名证书_Certificate_Credentials_Trust - Fatal编程技术网

Certificate SwiftHTTP凭据和自签名证书

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

我正在使用SwiftHTTP并尝试从我的服务器获取JSON提要。服务器具有自签名证书,并可通过用户和密码进行访问

我试着用阿拉莫菲尔,但没有找到解决办法

这是我的密码

   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)")
    }



     }
有人有主意吗