I have created self sign certificate and write code as below to start local server with SSL signed certificates
init() throws {
// Configure TLS
let tlsOptions = NWProtocolTLS.Options()
do {
try configureTLS(tlsOptions)
} catch {
throw error
}
// Disable strict certificate validation (DEBUG ONLY)
sec_protocol_options_set_verify_block(tlsOptions.securityProtocolOptions, { sec, trust, complete in
complete(true) // Always trust (Only for local testing!)
}, DispatchQueue.global())
print("TLSOption : \(tlsOptions)")
// Create NWParameters
let parameters = NWParameters(tls: tlsOptions)
parameters.allowLocalEndpointReuse = true
parameters.includePeerToPeer = true
// WebSocket options
let webSocketOptions = NWProtocolWebSocket.Options()
webSocketOptions.autoReplyPing = true
parameters.defaultProtocolStack.applicationProtocols.append(webSocketOptions)
// Create listener
self.listener = try NWListener(using: parameters, on: self.port)
}
when start server then it works fine on this url ws://192.168.11.223:8080 but when I hit wss://192.168.11.223:8080 then it not connected.
How to start local server for websocket with wss://
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744995422a4605158.html
评论列表(0条)