Skip to content

Commit

Permalink
Rename enforceTls to requireTls
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
  • Loading branch information
piotrpio committed Feb 15, 2024
1 parent 8ca251b commit cf2703f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Sources/NatsSwift/NatsClient/NatsClientOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ClientOptions {
return self
}

public func enforceTls() -> ClientOptions {
public func requireTls() -> ClientOptions {
self.withTls = true
return self
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public class ClientOptions {
maxReconnects: maxReconnects,
pingInterval: pingInterval,
auth: auth,
withTls: withTls,
requireTls: withTls,
tlsFirst: tlsFirst,
clientCertificate: clientCertificate,
clientKey: clientKey,
Expand Down
10 changes: 5 additions & 5 deletions Sources/NatsSwift/NatsConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ConnectionHandler: ChannelInboundHandler {
internal let reconnectWait: UInt64
internal let maxReconnects: Int?
internal let pingInterval: TimeInterval
internal let withTls: Bool
internal let requireTls: Bool
internal let tlsFirst: Bool
internal var rootCertificate: URL?
internal var clientCertificate: URL?
Expand Down Expand Up @@ -137,7 +137,7 @@ class ConnectionHandler: ChannelInboundHandler {
}
init(
inputBuffer: ByteBuffer, urls: [URL], reconnectWait: TimeInterval, maxReconnects: Int?,
pingInterval: TimeInterval, auth: Auth?, withTls: Bool, tlsFirst: Bool,
pingInterval: TimeInterval, auth: Auth?, requireTls: Bool, tlsFirst: Bool,
clientCertificate: URL?, clientKey: URL?,
rootCertificate: URL?
) {
Expand All @@ -150,7 +150,7 @@ class ConnectionHandler: ChannelInboundHandler {
self.maxReconnects = maxReconnects
self.auth = auth
self.pingInterval = pingInterval
self.withTls = withTls
self.requireTls = requireTls
self.tlsFirst = tlsFirst
self.clientCertificate = clientCertificate
self.clientKey = clientKey
Expand All @@ -175,7 +175,7 @@ class ConnectionHandler: ChannelInboundHandler {
value: 1
)
.channelInitializer { channel in
if self.withTls && self.tlsFirst {
if self.requireTls && self.tlsFirst {
var tlsConfiguration = TLSConfiguration.makeClientConfiguration()
do {
if let rootCertificate = self.rootCertificate {
Expand Down Expand Up @@ -239,7 +239,7 @@ class ConnectionHandler: ChannelInboundHandler {
// Wait for the first message after sending the connect request
}
self.serverInfo = info
if (info.tlsRequired ?? false || self.withTls) && !self.tlsFirst {
if (info.tlsRequired ?? false || self.requireTls) && !self.tlsFirst {
var tlsConfiguration = TLSConfiguration.makeClientConfiguration()
if let rootCertificate = self.rootCertificate {
tlsConfiguration.trustRoots = .file(rootCertificate.path)
Expand Down
8 changes: 4 additions & 4 deletions Tests/NatsSwiftTests/Integration/ConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class CoreNatsTests: XCTestCase {
natsServer.start()
let client = ClientOptions()
.url(URL(string: "tls://demo.nats.io:4222")!)
.enforceTls()
.requireTls()
.build()

try await client.connect()
Expand All @@ -284,7 +284,7 @@ class CoreNatsTests: XCTestCase {
"Integration/Resources/certs/rootCA.pem", isDirectory: false)
let client = ClientOptions()
.url(URL(string: natsServer.clientURL)!)
.enforceTls()
.requireTls()
.rootCertificates(certsURL)
.clientCertificate(
testsDir.appendingPathComponent(
Expand Down Expand Up @@ -314,7 +314,7 @@ class CoreNatsTests: XCTestCase {
"Integration/Resources/certs/rootCA.pem", isDirectory: false)
let client = ClientOptions()
.url(URL(string: natsServer.clientURL)!)
.enforceTls()
.requireTls()
.rootCertificates(certsURL)
.clientCertificate(
testsDir.appendingPathComponent(
Expand Down Expand Up @@ -345,7 +345,7 @@ class CoreNatsTests: XCTestCase {
"Integration/Resources/certs/rootCA.pem", isDirectory: false)
let client = ClientOptions()
.url(URL(string: natsServer.clientURL)!)
.enforceTls()
.requireTls()
.rootCertificates(certsURL)
.clientCertificate(
testsDir.appendingPathComponent(
Expand Down

0 comments on commit cf2703f

Please sign in to comment.