     private var session: NSURLSession!
     private var bridge: WebCacheFetcherBridge!
 
-    public init(configuration: NSURLSessionConfiguration? = nil) {
-        self.bridge = WebCacheFetcherBridge(fetcher: self)
+    public init(configuration: NSURLSessionConfiguration? = nil, trustSelfSignedServer: Bool = false) {
+        self.bridge = WebCacheFetcherBridge(trustSelfSignedServer: trustSelfSignedServer)
         self.session = NSURLSession(configuration: configuration ?? NSURLSessionConfiguration.ephemeralSessionConfiguration(), delegate: self.bridge, delegateQueue: nil)
     }
 

//---------------------------------------------------------------------------

private class WebCacheFetcherBridge : NSObject, NSURLSessionDataDelegate {
    unowned var fetcher: WebCacheFetcher

    init(fetcher: WebCacheFetcher) {
        self.fetcher = fetcher
    }

    func abortTask(task: NSURLSessionTask, error: NSError?) {

    @objc func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, willCacheResponse proposedResponse: NSCachedURLResponse, completionHandler: (NSCachedURLResponse?) -> Void) {
        completionHandler(nil)
    }

    @objc func URLSession(session: NSURLSession, didReceiveChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
        if self.trustSelfSignedServer && challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
            let credential = NSURLCredential(forTrust: challenge.protectionSpace.serverTrust!)
            completionHandler(.UseCredential, credential)
        } else {
            completionHandler(.PerformDefaultHandling, nil)
        }
    }
}

