Post

Replies

Boosts

Views

Activity

Reply to Using Network Framework + Bonjour + QUIC + TLS
Thanks for the response! For UDP, there’s DTLS but I’ve never looked as to whether that supports PSK or not. I tried this and it worked extension NWParameters { convenience init(passcode: String) { let udpOptions = NWProtocolUDP.Options() self.init(dtls: NWParameters.tlsOptions(passcode: passcode), udp: udpOptions) self.includePeerToPeer = true } private static func tlsOptions(passcode: String) -> NWProtocolTLS.Options { let tlsOptions = NWProtocolTLS.Options() let authenticationKey = SymmetricKey(data: passcode.data(using: .utf8)!) let authenticationCode = HMAC<SHA256>.authenticationCode(for: "HI".data(using: .utf8)!, using: authenticationKey) let authenticationDispatchData = authenticationCode.withUnsafeBytes { DispatchData(bytes: $0) } sec_protocol_options_add_pre_shared_key(tlsOptions.securityProtocolOptions, authenticationDispatchData as __DispatchData, stringToDispatchData("HI")! as __DispatchData) sec_protocol_options_append_tls_ciphersuite(tlsOptions.securityProtocolOptions, tls_ciphersuite_t(rawValue: TLS_PSK_WITH_AES_128_GCM_SHA256)!) return tlsOptions } // Create a utility function to encode strings as preshared key data. private static func stringToDispatchData(_ string: String) -> DispatchData? { guard let stringData = string.data(using: .utf8) else { return nil } let dispatchData = stringData.withUnsafeBytes { DispatchData(bytes: $0) } return dispatchData } } I was able to send messages back and forth. However, it sounds like you’re just testing out QUIC right now, and hard coding a digital identity for the purposes of your test is fine. I would like to hard code a digital identity to be able to test - do you have a resource that could help along that process? If it comes time to do this correctly, you’ll want to find a way to: Generate the digital identity on the server side. Distribute that digital identity to all the clients. I am using AppWrite as my backend service (it's similar to firebase). Would the idea / flow be as follows: user signs in on the mobile app make request to my backend requesting identity to be generated respond with generated identity use identity to secure QUIC connections In the extreme example the user would have 7 devices where they use the same credentials to sign in. Would each device need to have the same identity that was generated on my backend in order to properly connect to each other?
Nov ’24
Reply to Using Network Framework + Bonjour + QUIC + TLS
would doing this be wrong in a production app? sec_protocol_options_set_verify_block(options.securityProtocolOptions, { (sec_protocol_metadata, sec_trust, sec_protocol_verify_complete) in sec_protocol_verify_complete(true) }, queue) I found this from this app https://github.com/paxsonsa/quic-swift-demo/blob/main/Sources/main.swift - I think he posted on this forum before.
Nov ’24
Reply to Using Network Framework + Bonjour + QUIC + TLS
Thanks for the reply and information. I am early in the development of my app so things can change. I want to be careful to not get captivated by what QUIC can offer if I don't really need it. A high level description of the app: up to 7 devices can all discover each other and connect to each other command messages are sent between the devices (ie Device A sends out a "take photo" command and it's sent to all the connected devices) media content is downloaded between devices (ie Device A download the photo that was taken by each peer) stream what the camera is see so the main / controller device can get a preview of what the other devices are seeing As I'm describing what the app does I'm thinking when a device is discovered two connections are opened up - a TCP connection used for commands and downloading and a UDP connection used for camera preview. When it comes to QUIC and your advice of hardcoding a digital identify - would that be ill-advised in production? Would a user be able to inspect the app payload and extract the hard coded digital identity and be a bad actor with it? No sensitive PPI data will be sent over the QUIC connection. I appreciate your input and advice.
Nov ’24
Reply to Using Network Framework + Bonjour + QUIC + TLS
I plan to only allow up to 6 connections (ie 7 devices all connected to each other) and the connections will be used for the following send command messages (ie "start recording", "stop recording", "take photo") fetch thumbnails of media on device and its URI to fetch download media content (ie photos and videos) from Device A to Device B streaming video (ie I will also want to stream video from Device B, C and D to Device A (ie Device A can get a preview of what Device B, C and D are seeing)) There could be a scenario where Device A is the "controller" and its connected to 3 other devices (B, C, D) and Device A requests a video from each other device - so it would be downloading 3 videos from 3 different devices. Is TCP "enough" for my use cases and is it worth it to try and use QUIC for the performance gains. Also, both the physical devices I am running the app on (iphone and ipad) are on iOS 18 If it's easier I can post my demo code in a public github repo.
Nov ’24