Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing further deprecation warnings. #797

Merged
merged 3 commits into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,13 @@ public class ClientCertificateManager {

let chainSize = SecTrustGetCertificateCount(trust)

if trustResult == .recoverableTrustFailure, chainSize > 1 {
trustResult = SecTrustResultType.proceed
let rootCA = SecTrustGetCertificateAtIndex(trust, chainSize - 1)
if trustResult == .recoverableTrustFailure, chainSize > 1,
let certificates = SecTrustCopyCertificateChain(trust) as? [SecCertificate] {
let rootCA = certificates[chainSize - 1]
let anchors = [rootCA]
os_log("Setting anchor for trust evaluation to %s", log: .default, type: .info, rootCA.debugDescription)
os_log("Setting anchor for trust evaluation to %s", log: .default, type: .info, SecCertificateCopySubjectSummary(rootCA)! as String)
SecTrustSetAnchorCertificates(trust, anchors as CFArray)
trustResult = SecTrustResultType.proceed
if #available(iOS 12.0, *) {
var trustError: CFError?
if SecTrustEvaluateWithError(trust, &trustError) != true {
Expand All @@ -316,13 +317,7 @@ public class ClientCertificateManager {
return nil
}

var certChain: [SecCertificate] = []
for ix in 0 ... chainSize - 1 {
guard let ct = SecTrustGetCertificateAtIndex(trust, ix) else { return nil }
if ct != cert {
certChain.append(ct)
}
}
return certChain
let certificates = SecTrustCopyCertificateChain(trust) as? [SecCertificate]
return certificates?.filter { $0 != cert }
}
}