Skip to content

Commit

Permalink
Converted the certificate and public key bundle methods to static met…
Browse files Browse the repository at this point in the history
…hods.
  • Loading branch information
cnoon committed Jul 19, 2015
1 parent 8094b36 commit 99d9b7e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Source/ServerTrustPolicy.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Alamofire.swift
// ServerTrustPolicy.swift
//
// Copyright (c) 2014–2015 Alamofire Software Foundation (http://alamofire.org/)
//
Expand Down Expand Up @@ -114,7 +114,7 @@ public enum ServerTrustPolicy {

:returns: All certificates within the given bundle.
*/
public func certificatesInBundle(bundle: NSBundle = NSBundle.mainBundle()) -> [SecCertificate] {
public static func certificatesInBundle(bundle: NSBundle = NSBundle.mainBundle()) -> [SecCertificate] {
var certificates: [SecCertificate] = []

for path in bundle.pathsForResourcesOfType(".cer", inDirectory: nil) as! [String] {
Expand All @@ -136,7 +136,7 @@ public enum ServerTrustPolicy {

:returns: All public keys within the given bundle.
*/
public func publicKeysInBundle(bundle: NSBundle = NSBundle.mainBundle()) -> [SecKey] {
public static func publicKeysInBundle(bundle: NSBundle = NSBundle.mainBundle()) -> [SecKey] {
var publicKeys: [SecKey] = []

for certificate in certificatesInBundle(bundle: bundle) {
Expand Down Expand Up @@ -200,8 +200,8 @@ public enum ServerTrustPolicy {
}

if certificateChainEvaluationPassed {
let serverKeys = publicKeysForTrust(serverTrust)
outerLoop: for serverPublicKey in publicKeysForTrust(serverTrust) as [AnyObject] {
let serverKeys = ServerTrustPolicy.publicKeysForTrust(serverTrust)
outerLoop: for serverPublicKey in ServerTrustPolicy.publicKeysForTrust(serverTrust) as [AnyObject] {
for pinnedPublicKey in pinnedPublicKeys as [AnyObject] {
if serverPublicKey.isEqual(pinnedPublicKey) {
serverTrustIsValid = true
Expand Down Expand Up @@ -256,7 +256,7 @@ public enum ServerTrustPolicy {

// MARK: - Private - Public Key Extraction

private func publicKeysForTrust(trust: SecTrust) -> [SecKey] {
private static func publicKeysForTrust(trust: SecTrust) -> [SecKey] {
var publicKeys: [SecKey] = []

for index in 0..<SecTrustGetCertificateCount(trust) {
Expand All @@ -270,7 +270,7 @@ public enum ServerTrustPolicy {
return publicKeys
}

private func publicKeyForCertificate(certificate: SecCertificate) -> SecKey? {
private static func publicKeyForCertificate(certificate: SecCertificate) -> SecKey? {
var publicKey: SecKey?

let policy = SecPolicyCreateBasicX509().takeRetainedValue()
Expand Down

0 comments on commit 99d9b7e

Please sign in to comment.