From bc4b5aaa899d4b9ab4e94666298ded6df60cf87f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 28 Feb 2022 12:51:22 +1300 Subject: [PATCH 1/2] Fix websocket client not respecting client self signed status --- templates/swift/Sources/Client.swift.twig | 3 +++ templates/swift/Sources/Services/Realtime.swift.twig | 2 +- .../swift/Sources/WebSockets/WebSocketClient.swift.twig | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/swift/Sources/Client.swift.twig b/templates/swift/Sources/Client.swift.twig index d883ee33e..4db463b77 100644 --- a/templates/swift/Sources/Client.swift.twig +++ b/templates/swift/Sources/Client.swift.twig @@ -29,6 +29,8 @@ open class Client { open var config: [String: String] = [:] + open var selfSigned: Bool = false + open var http: HTTPClient private static let boundaryChars = @@ -119,6 +121,7 @@ open class Client { /// @return Client /// open func setSelfSigned(_ status: Bool = true) -> Client { + self.selfSigned = status try! http.syncShutdown() http = Client.createHTTP(selfSigned: status) return self diff --git a/templates/swift/Sources/Services/Realtime.swift.twig b/templates/swift/Sources/Services/Realtime.swift.twig index 76b8f480e..d91b29db3 100644 --- a/templates/swift/Sources/Services/Realtime.swift.twig +++ b/templates/swift/Sources/Services/Realtime.swift.twig @@ -38,7 +38,7 @@ open class Realtime : Service { reconnect = false closeSocket() } else { - socketClient = WebSocketClient(url, delegate: self)! + socketClient = WebSocketClient(url, tlsEnabled: !client.selfSigned, delegate: self)! } try! socketClient?.connect() diff --git a/templates/swift/Sources/WebSockets/WebSocketClient.swift.twig b/templates/swift/Sources/WebSockets/WebSocketClient.swift.twig index 67cc39652..d67ec5d71 100644 --- a/templates/swift/Sources/WebSockets/WebSocketClient.swift.twig +++ b/templates/swift/Sources/WebSockets/WebSocketClient.swift.twig @@ -172,7 +172,7 @@ public class WebSocketClient { frameKey: String, headers: HTTPHeaders = HTTPHeaders(), maxFrameSize: Int = 14, - tlsEnabled: Bool = false, + tlsEnabled: Bool = true, delegate: WebSocketClientDelegate? = nil ) { self.host = host @@ -193,19 +193,19 @@ public class WebSocketClient { /// - delegate: Delegate to handle message and error callbacks. public init?( _ url: String, + tlsEnabled: Bool = true, headers: HTTPHeaders = HTTPHeaders(), delegate: WebSocketClientDelegate? = nil ) { let rawUrl = URL(string: url) - let hasTLS = rawUrl?.scheme == "wss" || rawUrl?.scheme == "https" self.frameKey = "tergregfgbsfdgfdsfgdbv==" self.host = rawUrl?.host ?? "localhost" - self.port = rawUrl?.port ?? (hasTLS ? 443 : 80) + self.port = rawUrl?.port ?? (tlsEnabled ? 443 : 80) self.uri = rawUrl?.path ?? "/" self.query = rawUrl?.query ?? "" self.headers = headers self.maxFrameSize = 24 - self.tlsEnabled = hasTLS + self.tlsEnabled = tlsEnabled self.delegate = delegate } From 78023fc52244a60f930f821724106d9dc20f2b84 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 1 Mar 2022 17:48:04 +1300 Subject: [PATCH 2/2] Fix test error for delete calls --- templates/php/src/Services/Service.php.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/php/src/Services/Service.php.twig b/templates/php/src/Services/Service.php.twig index 0edb8f0b3..c44f7a5f3 100644 --- a/templates/php/src/Services/Service.php.twig +++ b/templates/php/src/Services/Service.php.twig @@ -20,10 +20,10 @@ class {{ service.name | caseUcfirst }} extends Service * @param {{ parameter.type | typeName }}${{ parameter.name | caseCamel | escapeKeyword }} {% endfor %} * @throws {{spec.title | caseUcfirst}}Exception - * @return {% if (method.type == 'location') or (method.method | caseUpper == 'DELETE') %}string{% else %}array{% endif %} + * @return {% if method.type == 'location' %}string{% else %}array{% endif %} */ - public function {{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{{ parameter.type | typeName }}${{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %} = null{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, callable $onProgress = null{% endif %}): {% if (method.type == 'location') or (method.method | caseUpper == 'DELETE') %}string{% else %}array{% endif %} + public function {{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{{ parameter.type | typeName }}${{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %} = null{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, callable $onProgress = null{% endif %}): {% if method.type == 'location' %}string{% else %}array{% endif %} { {% for parameter in method.parameters.all %}