0

I'm building a secure VoIP iOS app using the Linphone SDK.

I set up media encryption right when the app starts:

linphone_core_set_media_encryption(theLinphone.lc, LinphoneMediaEncryptionZRTP)

And I am trying to retrieve the SAS like this:

linphone_call_get_authentication_token(Call.current())

Most times it returns nil. But once in a while it returns a Hexadecimal value like 0x35422f6e6f697461

I even get this log: ortp-message-ZRTP secrets on: SAS is xxxx previously verified no being "xxxx" the correct SAS.

gabriel_vincent
  • 1,230
  • 3
  • 16
  • 35

1 Answers1

0

So I figured out what was happening.

I was calling linphone_call_get_authentication_token(Call.current()) immediately after the call state changed to LinphoneCallOutgoingProgress. All I had to do to fix it was to start a Timer that calls a method every 1 second when the call state changes to LinphoneCallOutgoingProgress because it takes sometime for the SAS to be generated it seems. Here's what worked for me:

timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) {

    DispatchQueue.main.async {

        let sas = linphone_call_get_authentication_token(Call.current())

        if sas != nil {

            self!.sasLabel.text = String(cString: sas!)
            timer.invalidate()
        }
    }
}
gabriel_vincent
  • 1,230
  • 3
  • 16
  • 35