//
//  NSURLRequest.swift
//
//  Created by Mark Sandstrom on 2/17/15.
//  Copyright (c) 2015 Mobify. All rights reserved.
//

import Foundation

// This is for when servers don't have valid certificates, so we
// accept any certificate. This extension only applies when we are not using
// the release configuration. Configuration is passed to the Swift compiler via
// a custom build setting:
//
// Build Settings > Swift Compiler - Custom Flags > Other Swift Flags > Debug:
// "-D DEBUG"
// Build Settings > Swift Compiler - Custom Flags > Other Swift Flags > UAT:
// "-D UAT"
// Build Settings > Swift Compiler - Custom Flags > Other Swift Flags > Release:
// "-D RELEASE"
// NOTE: If you set this, you should know what you're doing

extension URLRequest {
    static func allowsAnyHTTPSCertificateForHost(_ string: String) -> ObjCBool {
#if !RELEASE
            return AstroConfig.allowUntrustedHTTPSCertificate
#else
            return false
#endif
    }
}
