@@ -141,9 +141,9 @@ public class SSLSecurity : NSObject {
141
141
}
142
142
var policy : SecPolicyRef
143
143
if self . validatedDN {
144
- policy = SecPolicyCreateSSL ( true , domain) !
144
+ policy = SecPolicyCreateSSL ( true , domain)
145
145
} else {
146
- policy = SecPolicyCreateBasicX509 ( ) !
146
+ policy = SecPolicyCreateBasicX509 ( )
147
147
}
148
148
SecTrustSetPolicies ( trust, policy)
149
149
if self . usePublicKeys {
@@ -164,10 +164,10 @@ public class SSLSecurity : NSObject {
164
164
collect. append ( SecCertificateCreateWithData ( nil , cert) !)
165
165
}
166
166
SecTrustSetAnchorCertificates ( trust, collect)
167
- var result = SecTrustResultType ( rawValue : 0 )
168
- SecTrustEvaluate ( trust, & result! )
169
- let r = Int ( result! . rawValue )
170
- if r == Int ( SecTrustResultType . Unspecified . rawValue ) || r == Int ( SecTrustResultType . Proceed . rawValue ) {
167
+ var result : SecTrustResultType = 0
168
+ SecTrustEvaluate ( trust, & result)
169
+ let r = Int ( result)
170
+ if r == kSecTrustResultUnspecified || r == kSecTrustResultProceed {
171
171
var trustedCount = 0
172
172
for serverCert in serverCerts {
173
173
for cert in certs {
@@ -195,7 +195,7 @@ public class SSLSecurity : NSObject {
195
195
func extractPublicKey( data: NSData ) -> SecKeyRef ? {
196
196
guard let cert = SecCertificateCreateWithData ( nil , data) else { return nil }
197
197
198
- return extractPublicKeyFromCert ( cert, policy: SecPolicyCreateBasicX509 ( ) ! )
198
+ return extractPublicKeyFromCert ( cert, policy: SecPolicyCreateBasicX509 ( ) )
199
199
}
200
200
201
201
/**
@@ -211,7 +211,7 @@ public class SSLSecurity : NSObject {
211
211
212
212
guard let trust = possibleTrust else { return nil }
213
213
214
- var result = SecTrustResultType ( rawValue : 0 ) !
214
+ var result : SecTrustResultType = 0
215
215
SecTrustEvaluate ( trust, & result)
216
216
return SecTrustCopyPublicKey ( trust)
217
217
}
@@ -246,7 +246,7 @@ public class SSLSecurity : NSObject {
246
246
let keys = ( 0 ..< SecTrustGetCertificateCount ( trust) ) . reduce ( [ SecKeyRef] ( ) ) { ( keys: [ SecKeyRef ] , index: Int ) -> [ SecKeyRef ] in
247
247
var keys = keys
248
248
let cert = SecTrustGetCertificateAtIndex ( trust, index)
249
- if let key = extractPublicKeyFromCert ( cert!, policy: policy! ) {
249
+ if let key = extractPublicKeyFromCert ( cert!, policy: policy) {
250
250
keys. append ( key)
251
251
}
252
252
@@ -257,4 +257,4 @@ public class SSLSecurity : NSObject {
257
257
}
258
258
259
259
260
- }
260
+ }
0 commit comments