Merge branch 'dev' into message-and-image-info

This commit is contained in:
ryanzhao 2023-04-05 14:37:00 +08:00
commit 1a672cdd0a
1 changed files with 17 additions and 0 deletions

View File

@ -41,8 +41,25 @@ public enum HTTP {
guard SecTrustSetAnchorCertificates(trust, certificates as CFArray) == errSecSuccess else {
return completionHandler(.cancelAuthenticationChallenge, nil)
}
// We want to make sure that the pinned certification was valid during it's validity
// period (which has now expired) so set the date to validate against to be within the
// valid period
let dateFormatter: DateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy HH:mm:ss"
if let validDate: Date = dateFormatter.date(from: "01/01/2022 12:00:00") {
if SecTrustSetVerifyDate(trust, validDate as CFDate) != errSecSuccess {
SNLog("Unable to set date for seed node certificate validation.")
}
}
else {
SNLog("Unable to set date for seed node certificate validation.")
}
// Check that the presented certificate is one of the seed node certificates
var result: SecTrustResultType = .invalid
guard SecTrustEvaluate(trust, &result) == errSecSuccess else {
return completionHandler(.cancelAuthenticationChallenge, nil)
}