Skip to content

Conversation

dimitribouniol
Copy link
Contributor

Added missing Hashable and Sendable conformances, since I was getting warnings after updating to 3.0.0:

image

I also audited the rest of the types and added it to some error types as well.

@@ -3,9 +3,9 @@
import Foundation

///A verifier and decoder class designed to decode signed data from the App Store.
public struct SignedDataVerifier {
public struct SignedDataVerifier: Sendable {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SignedDataVerifier must be sendable in order for it to be used by multiple concurrent tasks at the same time. This means that ChainVerifier must be updated to an actor to properly prevent data race issues.

@@ -28,7 +27,7 @@ class ChainVerifier {
self.verifiedPublicKeyCache = [:]
}

func verify<T: DecodedSignedData>(signedData: String, type: T.Type, onlineVerification: Bool, environment: AppStoreEnvironment) async -> VerificationResult<T> where T: Decodable {
func verify<T: DecodedSignedData>(signedData: String, type: T.Type, onlineVerification: Bool, environment: AppStoreEnvironment) async -> VerificationResult<T> where T: Decodable & Sendable {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since ChainVerifier is now an actor, T must be Sendable here.

@@ -120,7 +119,7 @@ class ChainVerifier {
return verificationResult
}

func verifyChainWithoutCaching(leaf: Certificate, intermediate: Certificate, online: Bool, validationTime: Date) async -> X509.VerificationResult {
nonisolated func verifyChainWithoutCaching(leaf: Certificate, intermediate: Certificate, online: Bool, validationTime: Date) async -> X509.VerificationResult {
var verifier = Verifier(rootCertificates: self.store) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Verifier is not Sendable, but becomes tied to the actor, we must mark this method nonisolated to detach this dependency and allow it to be safely used within the context of this method.

Comment on lines -135 to 136
func getDate() -> Date {
nonisolated func getDate() -> Date {
return Date()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the intent on making a separate getDate() method was, but it must now be nonisolated so it can be called by the above method, which is also nonisolated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant