From 30e3a82cb34c582ecd1eeb0365815fa15a98dc37 Mon Sep 17 00:00:00 2001 From: David Nadoba Date: Thu, 21 Mar 2024 16:20:43 +0000 Subject: [PATCH 1/3] Fix `Sendable` warnings on main --- Sources/X509/Error.swift | 2 +- Sources/X509/OCSP/OCSPPolicy.swift | 1 + Sources/X509/PromiseAndFuture.swift | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/X509/Error.swift b/Sources/X509/Error.swift index a53615b5..2c6764b1 100644 --- a/Sources/X509/Error.swift +++ b/Sources/X509/Error.swift @@ -22,7 +22,7 @@ /// This type is `Equatable` and `Hashable`, but only the ``code`` field is considered in the /// implementation of that behaviour. This makes it relatively easy to test code that throws /// a specific error by creating the error type directly in your own code. -public struct CertificateError: Error, Hashable, CustomStringConvertible { +public struct CertificateError: Error, Hashable, CustomStringConvertible, @unchecked Sendable /* CoW */ { private var backing: Backing /// Represents the kind of error that was encountered. diff --git a/Sources/X509/OCSP/OCSPPolicy.swift b/Sources/X509/OCSP/OCSPPolicy.swift index 78863bf0..9b32f6fd 100644 --- a/Sources/X509/OCSP/OCSPPolicy.swift +++ b/Sources/X509/OCSP/OCSPPolicy.swift @@ -320,6 +320,7 @@ extension OCSPVerifierPolicy.Storage { return responderURI }.first guard let responderURI else { + let ocspAccessDescriptions = Array(ocspAccessDescriptions) return self.softFailure( reason: .init("expected OCSP location to be a URI but got \(ocspAccessDescriptions)") ) diff --git a/Sources/X509/PromiseAndFuture.swift b/Sources/X509/PromiseAndFuture.swift index b1e3a8c9..fab152e4 100644 --- a/Sources/X509/PromiseAndFuture.swift +++ b/Sources/X509/PromiseAndFuture.swift @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// // MARK: - Promise -final class Promise { +final class Promise { private enum State { case unfulfilled(observers: [CheckedContinuation, Never>]) case fulfilled(Result) @@ -83,7 +83,7 @@ extension Promise { // MARK: - Future -struct Future { +struct Future { private let promise: Promise init(_ promise: Promise) { From b6d643aa77c17530b07324109c98e21b8b6afdc9 Mon Sep 17 00:00:00 2001 From: David Nadoba Date: Thu, 21 Mar 2024 17:09:05 +0000 Subject: [PATCH 2/3] remove `@preconcurrency` from `import _CryptoExtras` --- Sources/X509/CertificatePrivateKey.swift | 2 +- Sources/X509/CertificatePublicKey.swift | 2 +- Sources/X509/Signature.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/X509/CertificatePrivateKey.swift b/Sources/X509/CertificatePrivateKey.swift index 0d8b8172..f1082ed1 100644 --- a/Sources/X509/CertificatePrivateKey.swift +++ b/Sources/X509/CertificatePrivateKey.swift @@ -15,7 +15,7 @@ import SwiftASN1 import Foundation @preconcurrency import Crypto -@preconcurrency import _CryptoExtras +import _CryptoExtras extension Certificate { /// A private key that can be used with a certificate. diff --git a/Sources/X509/CertificatePublicKey.swift b/Sources/X509/CertificatePublicKey.swift index c709c035..9d9c4dd6 100644 --- a/Sources/X509/CertificatePublicKey.swift +++ b/Sources/X509/CertificatePublicKey.swift @@ -14,7 +14,7 @@ import SwiftASN1 @preconcurrency import Crypto -@preconcurrency import _CryptoExtras +import _CryptoExtras import Foundation extension Certificate { diff --git a/Sources/X509/Signature.swift b/Sources/X509/Signature.swift index 400fc10f..fe31f8fb 100644 --- a/Sources/X509/Signature.swift +++ b/Sources/X509/Signature.swift @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// import SwiftASN1 -@preconcurrency import _CryptoExtras +import _CryptoExtras import Foundation extension Certificate { From 34b01d01f74d5b182bf72c01a230538bf628f926 Mon Sep 17 00:00:00 2001 From: David Nadoba Date: Thu, 21 Mar 2024 17:13:54 +0000 Subject: [PATCH 3/3] move documentation to extensions --- Sources/X509/Error.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/X509/Error.swift b/Sources/X509/Error.swift index 2c6764b1..984abac0 100644 --- a/Sources/X509/Error.swift +++ b/Sources/X509/Error.swift @@ -22,7 +22,7 @@ /// This type is `Equatable` and `Hashable`, but only the ``code`` field is considered in the /// implementation of that behaviour. This makes it relatively easy to test code that throws /// a specific error by creating the error type directly in your own code. -public struct CertificateError: Error, Hashable, CustomStringConvertible, @unchecked Sendable /* CoW */ { +public struct CertificateError: Error, Hashable, CustomStringConvertible { private var backing: Backing /// Represents the kind of error that was encountered. @@ -249,6 +249,9 @@ public struct CertificateError: Error, Hashable, CustomStringConvertible, @unche } } +// `CertificateError` is `Sendable` because it uses CoW +extension CertificateError: @unchecked Sendable {} + extension CertificateError { /// Represents the kind of an error. ///