How to use AES encryption with a Swift iOS client?

Hello,

I wonder if there is any example that shows how to setup the needed code to add an AESEnvelope to a client channel in swift?

I’m somewhat lost on how to setup the envelopes dictionary (what should be the key value? for instance) using as basis the ServerAccess code that the ServiceImporter generates.

By the way: it would be very nice if you could provide the needed code, commented, in the ServerAccess code generated.

Thanks!

This code apparently works fine:

  public var TSBackupsService: Backups_Proxy {
    get {
      let message = ROBinMessage(matchingTargetURL: self.serverURL)
      
      let clientchannel = ROTCPClientChannel(targetURL: self.serverURL)
      
      let envelope = ROAESEncryptionEnvelope(password: "thepassword")
      
      message.envelopes!["AES"] = envelope
      
      let service = RORemoteService(message: message, channel: clientchannel, serviceName: "Backups")

      service.channel.delegate = self
      return Backups_Proxy(service: service)
    }
  }

But I don’t know if this is the optimum way to do it? Maybe there is a simpler way?

Looks good to me. I don’t think it could get much simpler, it’s essentially one line of code (split in two in your case), create the envelope and put it in the dictionary?