Skip to content

Commit af884fb

Browse files
committed
Allow errors thrown by SecCertificateCreateWithData to passed up the callstack
1 parent c6f048d commit af884fb

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Sources/AsyncHTTPClient/NIOTransportServices/TLSConfiguration.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
///
6161
/// - Parameter queue: Dispatch queue to run `sec_protocol_options_set_verify_block` on.
6262
/// - Returns: Equivalent NWProtocolTLS Options
63-
func getNWProtocolTLSOptions() -> NWProtocolTLS.Options {
63+
func getNWProtocolTLSOptions() throws -> NWProtocolTLS.Options {
6464
let options = NWProtocolTLS.Options()
6565

6666
let useMTELGExplainer = """
@@ -125,12 +125,8 @@
125125
var secTrustRoots: [SecCertificate]?
126126
switch trustRoots {
127127
case .some(.certificates(let certificates)):
128-
do {
129-
secTrustRoots = try certificates.compactMap { certificate in
130-
try SecCertificateCreateWithData(nil, Data(certificate.toDERBytes()) as CFData)
131-
}
132-
} catch {
133-
// failed to load
128+
secTrustRoots = try certificates.compactMap { certificate in
129+
try SecCertificateCreateWithData(nil, Data(certificate.toDERBytes()) as CFData)
134130
}
135131
case .some(.file):
136132
preconditionFailure("TLSConfiguration.trustRoots.file is not supported")

0 commit comments

Comments
 (0)