AlamofireExtension
public struct AlamofireExtension<ExtendedType>
Type that acts as a generic extension point for all AlamofireExtended
types.
-
Stores the type or meta-type of any extended type.
Declaration
Swift
public private(set) var type: ExtendedType { get }
-
Create an instance from the provided value.
Declaration
Swift
public init(_ type: ExtendedType)
Parameters
type
Instance being extended.
-
Alamofire’s default configuration. Same as
URLSessionConfiguration.default
but adds Alamofire defaultAccept-Language
,Accept-Encoding
, andUser-Agent
headers.Declaration
Swift
public static var `default`: URLSessionConfiguration { get }
-
.ephemeral
configuration with Alamofire’s defaultAccept-Language
,Accept-Encoding
, andUser-Agent
headers.Declaration
Swift
public static var ephemeral: URLSessionConfiguration { get }
-
Returns all valid
cer
,crt
, andder
certificates in the bundle.Declaration
Swift
public var certificates: [SecCertificate] { get }
-
Returns all public keys for the valid certificates in the bundle.
Declaration
Swift
public var publicKeys: [SecKey] { get }
-
Returns all pathnames for the resources identified by the provided file extensions.
Declaration
Swift
public func paths(forResourcesOfTypes types: [String]) -> [String]
Parameters
types
The filename extensions locate.
Return Value
All pathnames for the given filename extensions.
-
Evaluates
self
after applying theSecPolicy
value provided.Throws
Any
Error
from applying theSecPolicy
or from evaluation.Declaration
Swift
@available(iOS 12, macOS 10.14, tvOS 12, watchOS 5, *) public func evaluate(afterApplying policy: SecPolicy) throws
Parameters
policy
The
SecPolicy
to apply toself
before evaluation. -
Attempts to validate
self
using theSecPolicy
provided and transforming any error produced using the closure passed.Throws
AnyError
from applying thepolicy
, or the result oferrorProducer
if validation fails.Declaration
Swift
@available(iOS, introduced: 10, deprecated: 12, renamed: "evaluate(afterApplying:﹚") @available(macOS, introduced: 10.12, deprecated: 10.14, renamed: "evaluate(afterApplying:﹚") @available(tvOS, introduced: 10, deprecated: 12, renamed: "evaluate(afterApplying:﹚") @available(watchOS, introduced: 3, deprecated: 5, renamed: "evaluate(afterApplying:﹚") public func validate(policy: SecPolicy, errorProducer: (_ status: OSStatus, _ result: SecTrustResultType) -> any Error) throws
Parameters
policy
The
SecPolicy
used to evaluateself
.errorProducer
The closure used transform the failed
OSStatus
andSecTrustResultType
. -
Applies a
SecPolicy
toself
, throwing if it fails.Throws
An
AFError.serverTrustEvaluationFailed
instance with a.policyApplicationFailed
reason.Declaration
Swift
public func apply(policy: SecPolicy) throws -> SecTrust
Parameters
policy
The
SecPolicy
.Return Value
self
, with the policy applied. -
Evaluate
self
, throwing anError
if evaluation fails.Throws
AFError.serverTrustEvaluationFailed
with reason.trustValidationFailed
and associated error from the underlying evaluation.Declaration
Swift
@available(iOS 12, macOS 10.14, tvOS 12, watchOS 5, *) public func evaluate() throws
-
Validate
self
, passing any failure values througherrorProducer
.Throws
TheError
produced by theerrorProducer
closure.Declaration
Swift
@available(iOS, introduced: 10, deprecated: 12, renamed: "evaluate(﹚") @available(macOS, introduced: 10.12, deprecated: 10.14, renamed: "evaluate(﹚") @available(tvOS, introduced: 10, deprecated: 12, renamed: "evaluate(﹚") @available(watchOS, introduced: 3, deprecated: 5, renamed: "evaluate(﹚") public func validate(errorProducer: (_ status: OSStatus, _ result: SecTrustResultType) -> any Error) throws
Parameters
errorProducer
The closure used to transform the failed
OSStatus
andSecTrustResultType
into anError
. -
Sets a custom certificate chain on
self
, allowing full validation of a self-signed certificate and its chain.Throws
Any error produced when applying the new certificate chain.Declaration
Swift
public func setAnchorCertificates(_ certificates: [SecCertificate]) throws
Parameters
certificates
The
SecCertificate
s to add to the chain. -
The public keys contained in
self
.Declaration
Swift
public var publicKeys: [SecKey] { get }
-
The
SecCertificate
s contained inself
.Declaration
Swift
public var certificates: [SecCertificate] { get }
-
The
Data
values for all certificates contained inself
.Declaration
Swift
public var certificateData: [Data] { get }
-
Validates
self
after applyingSecPolicy.af.default
. This evaluation does not validate the hostname.Throws
AnAFError.serverTrustEvaluationFailed
instance with a.defaultEvaluationFailed
reason.Declaration
Swift
public func performDefaultValidation(forHost host: String) throws
Parameters
host
The hostname, used only in the error output if validation fails.
-
Validates
self
after applyingSecPolicy.af.hostname(host)
, which performs the default validation as well as hostname validation.Throws
AnAFError.serverTrustEvaluationFailed
instance with a.defaultEvaluationFailed
reason.Declaration
Swift
public func performValidation(forHost host: String) throws
Parameters
host
The hostname to use in the validation.
-
Creates a
SecPolicy
instance which will validate server certificates but not require a host name match.Declaration
Swift
public static let `default`: SecPolicy
-
Creates a
SecPolicy
instance which will validate server certificates and much match the provided hostname.Declaration
Swift
public static func hostname(_ hostname: String) -> SecPolicy
Parameters
hostname
The hostname to validate against.
Return Value
The
SecPolicy
. -
Creates a
SecPolicy
which checks the revocation of certificates.Throws
An
AFError.serverTrustEvaluationFailed
error with reason.revocationPolicyCreationFailed
if the policy cannot be created.Declaration
Swift
public static func revocation(options: RevocationTrustEvaluator.Options) throws -> SecPolicy
Parameters
options
The
RevocationTrustEvaluator.Options
for evaluation.Return Value
The
SecPolicy
.
-
All
Data
values for the containedSecCertificate
s.Declaration
Swift
public var data: [Data] { get }
-
All public
SecKey
values for the containedSecCertificate
s.Declaration
Swift
public var publicKeys: [SecKey] { get }
-
The public key for
self
, if it can be extracted.Note
On 2020 OSes and newer, only RSA and ECDSA keys are supported.Declaration
Swift
public var publicKey: SecKey? { get }
-
Returns whether
self
iserrSecSuccess
.Declaration
Swift
public var isSuccess: Bool { get }
-
Returns whether
self
is.unspecified
or.proceed
.Declaration
Swift
public var isSuccess: Bool { get }