|
115 | 115 | case .some(.certificates(let certificates)):
|
116 | 116 | do {
|
117 | 117 | secTrustRoots = try certificates.compactMap { certificate in
|
118 |
| - return try SecCertificateCreateWithData(nil, Data(certificate.toDERBytes()) as CFData) |
| 118 | + try SecCertificateCreateWithData(nil, Data(certificate.toDERBytes()) as CFData) |
119 | 119 | }
|
120 | 120 | } catch {
|
121 | 121 | // failed to load
|
122 | 122 | }
|
123 | 123 | case .some(.file):
|
124 | 124 | preconditionFailure("TLSConfiguration.trustRoots.file is not supported")
|
125 |
| - break |
126 | 125 |
|
127 | 126 | case .some(.default), .none:
|
128 | 127 | break
|
|
134 | 133 | // add verify block to control certificate verification
|
135 | 134 | sec_protocol_options_set_verify_block(
|
136 | 135 | options.securityProtocolOptions,
|
137 |
| - { sec_metadata, sec_trust, sec_protocol_verify_complete in |
| 136 | + { _, sec_trust, sec_protocol_verify_complete in |
138 | 137 | guard self.certificateVerification != .none else {
|
139 | 138 | sec_protocol_verify_complete(true)
|
140 | 139 | return
|
|
145 | 144 | SecTrustSetAnchorCertificates(trust, trustRootCertificates as CFArray)
|
146 | 145 | }
|
147 | 146 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) {
|
148 |
| - SecTrustEvaluateAsyncWithError(trust, Self.tlsDispatchQueue) { (trust, result, error) in |
| 147 | + SecTrustEvaluateAsyncWithError(trust, Self.tlsDispatchQueue) { _, result, error in |
149 | 148 | if let error = error {
|
150 | 149 | print("Trust failed: \(error.localizedDescription)")
|
151 | 150 | }
|
152 | 151 | sec_protocol_verify_complete(result)
|
153 | 152 | }
|
154 | 153 | } else {
|
155 |
| - SecTrustEvaluateAsync(trust, Self.tlsDispatchQueue) { (trust, result) in |
156 |
| - switch result { |
157 |
| - case .proceed, .unspecified: |
| 154 | + SecTrustEvaluateAsync(trust, Self.tlsDispatchQueue) { _, result in |
| 155 | + switch result { |
| 156 | + case .proceed, .unspecified: |
158 | 157 | sec_protocol_verify_complete(true)
|
159 |
| - default: |
| 158 | + default: |
160 | 159 | sec_protocol_verify_complete(false)
|
161 |
| - } |
| 160 | + } |
162 | 161 | }
|
163 | 162 | }
|
164 | 163 | }, Self.tlsDispatchQueue
|
|
0 commit comments