Skip to content

Commit 9b574aa

Browse files
committed
Allow errors thrown by SecCertificateCreateWithData to passed up the callstack
1 parent 18df79a commit 9b574aa

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
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
// minimum TLS protocol
@@ -113,12 +113,8 @@
113113
var secTrustRoots: [SecCertificate]?
114114
switch trustRoots {
115115
case .some(.certificates(let certificates)):
116-
do {
117-
secTrustRoots = try certificates.compactMap { certificate in
118-
try SecCertificateCreateWithData(nil, Data(certificate.toDERBytes()) as CFData)
119-
}
120-
} catch {
121-
// failed to load
116+
secTrustRoots = try certificates.compactMap { certificate in
117+
try SecCertificateCreateWithData(nil, Data(certificate.toDERBytes()) as CFData)
122118
}
123119
case .some(.file):
124120
preconditionFailure("TLSConfiguration.trustRoots.file is not supported")

Sources/AsyncHTTPClient/Utils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ extension NIOClientTCPBootstrap {
8989
} else {
9090
// create NIOClientTCPBootstrap with NIOTS TLS provider
9191
let tlsConfiguration = configuration.tlsConfiguration ?? TLSConfiguration.forClient()
92-
let parameters = tlsConfiguration.getNWProtocolTLSOptions()
92+
let parameters = try tlsConfiguration.getNWProtocolTLSOptions()
9393
let tlsProvider = NIOTSClientTLSProvider(tlsOptions: parameters)
9494
bootstrap = NIOClientTCPBootstrap(tsBootstrap, tls: tlsProvider)
9595
}

0 commit comments

Comments
 (0)