         
     }
     
-    private func trustIsValid(_ trust:SecTrust) -> Bool {
+    static func trustIsValid(_ trust:SecTrust) -> Bool {
         var isValid = false
         
         var result = SecTrustResultType.invalid

    
    public var progressHandler:progressHandler?
    public var response:URLResponse?
    
    
    //懒加载,需要的时候创建对象
    public lazy var data:Data = Data()

    }
    
    public func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Swift.Void){
        
        var disposition: Foundation.URLSession.AuthChallengeDisposition = .performDefaultHandling
        var credential:URLCredential? = self.credential
        
        if let handler:challengeHandler = challengeHandler {
            
            (disposition, credential) = handler(session, challenge)
            
        } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
            //1.认证方法是服务端信任
            
            //2.如果服务端信任存在
            if let serverTrust = challenge.protectionSpace.serverTrust {
                //3.验证服务端的信任
                if WTURLSessionDelegate.trustIsValid(serverTrust) {
                    //4.如果验证成功了,使用服务端的信任创建凭据
                    credential = URLCredential(trust: serverTrust)
                }
