admin管理员组

文章数量:1410674

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://

本文标签: How to start local server with websocket for WebRTC with SSL certificate in iOS swiftStack Overflow