0

I have recently updated my Linphone library from latest release to follow Apple’s IPV6 standard support. But it fails to create secure call. Each time i try to convert call to secure call ,Acknowledgment fails and SAS returns null. Same thing working with old library(IPV4 Support). I am using ZRTP Encryption for Secure call.

I am struggling with since last 15 days. Below line of code returns SAS value null.

NSString *localLize = NSLocalizedString(@"Confirm the following SAS with peer:\n%s", nil);
            const char *authToken = linphone_call_get_authentication_token(call);
            NSLog(@"localize %@ authToken %s",localLize,authToken);

Below is full function to convert call to security call.

- (IBAction)onSecurityClick:(id)sender {
if (linphone_core_get_calls_nb(LC)) {
    LinphoneCall *call = linphone_core_get_current_call(LC);
    if (call != NULL) {

        //force encryption ZRTP
        LinphoneMediaEncryption enc = LinphoneMediaEncryptionZRTP;

        if (enc == LinphoneMediaEncryptionZRTP) {

            NSString *localLize = NSLocalizedString(@"Confirm the following SAS with peer:\n%s", nil);
            const char *authToken = linphone_call_get_authentication_token(call);
            NSLog(@"localize %@ authToken %s",localLize,authToken);


            NSString *message =
                [NSString stringWithFormat:NSLocalizedString(@"Confirm the following SAS with peer:\n%s", nil),
                                           linphone_call_get_authentication_token(call)];
            if (securityDialog == nil) {
                __block __strong StatusBarView *weakSelf = self;
                securityDialog = [UIConfirmationDialog ShowWithMessage:message
                    cancelMessage:NSLocalizedString(@"DENY", nil)
                    confirmMessage:NSLocalizedString(@"ACCEPT", nil)
                    onCancelClick:^() {
                      if (linphone_core_get_current_call(LC) == call) {
                          linphone_call_set_authentication_token_verified(call, NO);
                      }
                      weakSelf->securityDialog = nil;
                    }
                    onConfirmationClick:^() {
                      if (linphone_core_get_current_call(LC) == call) {
                          linphone_call_set_authentication_token_verified(call, YES);
                      }
                      weakSelf->securityDialog = nil;
                    }];
            }
        }
    }
   }
}

Any help should be appreciable.

Thanks in Advance.

technerd
  • 14,144
  • 10
  • 61
  • 92

1 Answers1

0

So I figured out what was the problem for me. Maybe can be useful for you too.

I was calling linphone_call_get_authentication_token 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 some time 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