Skip to content

Commit d38ac5e

Browse files
Allow passing of TLSConfiguration as optional in constructor
- For using amqps it may be neccessary to allow self-signed certs, and being able to pass this configuration enables the user to do this.
1 parent cf518d8 commit d38ac5e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/AMQPClient/AMQPConnectionConfiguration.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public extension AMQPConnectionConfiguration {
7171
}
7272
}
7373

74-
init(url: String) throws {
74+
init(url: String, tls: TLSConfiguration? = nil) throws {
7575
guard let url = URL(string: url) else { throw AMQPConnectionError.invalidUrl }
76-
try self.init(url: url)
76+
try self.init(url: url, tls: tls)
7777
}
78-
79-
init(url: URL) throws {
78+
79+
init(url: URL, tls: TLSConfiguration? = nil) throws {
8080
guard let scheme = UrlScheme(rawValue: url.scheme ?? "") else { throw AMQPConnectionError.invalidUrlScheme }
8181

8282
// there is no such thing as a "" host
@@ -97,7 +97,7 @@ public extension AMQPConnectionConfiguration {
9797

9898
switch scheme {
9999
case .amqp: self = .init(connection: .plain, server: server)
100-
case .amqps: self = .init(connection: .tls(nil, sniServerName: nil), server: server)
100+
case .amqps: self = .init(connection: .tls(tls, sniServerName: nil), server: server)
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)