当我在 IOS 中集成 CCAvenue 支付网关方式时,我得到 Exe_Bad_Access(code=1 address=0X38)

I am getting Exe_Bad_Access(code=1 address=0X38) when I am integrating the CCAvenue Payment Gate way in IOS

我按照以下步骤集成了 non-shameless CCAvenue GateWay

步骤:-

我有我的商家 ID 和访问代码 (url,ip)。

  1. 我正在调用我的服务器以获取 RSA 密钥参数 (access_code ,order_id)

// 我的服务器已经在 CCAvenue 服务器上注册了 2.my 服务器调用 Avenue 获取 RSA 密钥

3.my 服务器转发 RSA 密钥

4.once 我知道我正在删除多余的行"\n ",双引号""--" ",和"\"

// removing double quates


 NSString * newReplacedString2 = [rsaKey stringByReplacingOccurrencesOfString:@"\"" withString:@""]; 

//removing /n in the key


  NSString * newReplacedString = [newReplacedString2 stringByReplacingOccurrencesOfString:@"\n" withString:@""];


 //removing / in the key

 NSString * newReplacedString1 = [newReplacedString stringByReplacingOccurrencesOfString:@"\" withString:@""]; 

5.and 我将那个键放在

之间
rsaKey = [NSString stringWithFormat:@"-----BEGIN PUBLIC KEY-----\n%@\n-----END PUBLIC KEY-----\n",newReplacedString1];

//*******//***//****//**//  output   //*******//***//****//**//
   -----BEGIN PUBLIC KEY-----
    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuV7OdmPSutrlOE9lF3YdW4ymGn+qselCOycMk95Tobw1PcqCeAWkrnxUECpAdnHGrUKmFbEDHs3wnwzLTbfa3GvE5dvvmluug78X3RYEFQiMh1QpfS5fBfvs4WQKw7oigko3G0UwZLZFnZ4E4WKTQi4wbCgjwQJFMnMGJfFYNcoSJluVg/q8z3bVxfDOV0ZPWccmvA3bTf9YFHKCC3clscQrGf1NPnBGcBGm+s06t3EljoSmpjtyTgSiGrqBZ8TSCQxoyXxS+RkhNTigg6mqW9hIisxYYqlbzvRnCDhuqgZfmP7t65QG5raELVE7d+Ia+dgh024luZ9+vSk4Qb65DQIDAQAB
    -----END PUBLIC KEY-----
  1. 我正在使用CCTool加密金额和价格

    NSString *myRequestString = [NSString stringWithFormat:@"amount=%@&currency=%@",amount,currency];(2,INR)
    CCTool *ccTool = [[CCTool alloc] init];
    NSString *encVal = [ccTool encryptRSA:myRequestString key:rsaKey];
    

因为我在

中得到Exe_Bad_Acess

RSA *rsa = PEM_read_bio_RSA_PUBKEY(bufio, NULL,NULL,NULL);

rsa 出现错误。

如何解决这个问题 issue.Please 帮帮我。!!

这一定是您从服务器获取的 return 密钥的问题。似乎服务器未在此处正确配置。我们有同样的问题。只需将此错误报告发送到此电子邮件:service@ccavenue.com

它的 CCAvenue 技术支持电子邮件。您可以索取他们的联系电话以获得技术支持,您在集成过程中遇到的任何技术问题都会很快得到解决。

根据报错信息可以看出发生了内存泄漏

我遇到过类似的错误

你可以试试我的方法

Xcode -> 编辑方案 -> 运行 -> 诊断 -> select Address Sanitizer

运行 你的项目。

嗨,谢谢大家的支持,我终于解决了我的问题。

一旦您从您的服务器获得 rsa 密钥,您需要删除新行“\n”、斜杠“\”和双引号“\”“

MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuV7OdmPSutrlOE9lF3YdW4ymGn+qselCOycMk95Tobw1PcqCeAWkrnxUECpAdnHGrUKmFbEDHs3wnwzLTbfa3GvE5dvvmluug78X3RYEFQiMh1QpfS5fBfvs4WQKw7oigko3G0UwZLZFnZ4E4WKTQi4wbCgjwQJFMnMGJfFYNcoSJluVg/q8z3bVxfDOV0ZPWccmvA3bTf9YFHKCC3clscQrGf1NPnBGcBGm+s06t3EljoSmpjtyTgSiGrqBZ8TSCQxoyXxS+RkhNTigg6mqW9hIisxYYqlbzvRnCDhuqgZfmP7t65QG5raELVE7d+Ia+dgh024luZ9+vSk4Qb65DQIDAQAB

这里需要转换成ba64加密格式的输入

https://gist.github.com/superwills/5415344#file-openssl-rsa-encryption-sample-L154

你需要完全相同地转换我们的字符串, 1. "string" 每行必须为64个字符宽。 2.it 必须以换行符结束

我正在更新我的 Code.For 我工作正常。

  NSString *rsaKey = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];

// NSString *rsaKey = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];

        NSLog(@"%@",rsaKey);

// rsaKey = [rsaKey stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; // NSLog(@"%@",rsaKey);

        // removing double quates
        NSString * newReplacedString2 = [rsaKey stringByReplacingOccurrencesOfString:@"\"" withString:@""];

        NSLog(@"%@",rsaKey);

        //removing \n in the key
        NSString * newReplacedString = [newReplacedString2 stringByReplacingOccurrencesOfString:@"\n" withString:@""];

        NSLog(@"%@",rsaKey);


        //removing \ in the key
        NSString * newReplacedString1 = [newReplacedString stringByReplacingOccurrencesOfString:@"\" withString:@""];
        NSLog(@"%@",newReplacedString1);


        NSString * abc = [NSString stringWithFormat:@"%@", newReplacedString1];
        NSMutableString *sss=[NSMutableString new];
        int j=(int)([abc length]/63);
        for (int i=0; i<=j; i++) {
            int k= i*63;
            NSString * newString;
            if (i != j) {
                newString = [abc substringWithRange:NSMakeRange(k,63)];
                NSLog(@"%lu",(unsigned long)newString.length);
                newString=[NSString stringWithFormat:@"%@",newString];
            }else{
                newString = [abc substringWithRange:NSMakeRange(k,[abc length]-k)];
                NSLog(@"%lu",(unsigned long)newString.length);
                if (newString.length !=0)
                    newString=[NSString stringWithFormat:@"%@",newString];
            }
            if (newString.length !=0)
                [sss appendString:[NSString stringWithFormat:@"%@\n",newString]];
        }
        NSLog(@"%@",sss);


        rsaKey = [NSString stringWithFormat:@"-----BEGIN PUBLIC KEY-----\n%@-----END PUBLIC KEY-----\n",sss];
        NSLog(@"%@",rsaKey);

        //Encrypting Card Details
            NSString *myRequestString = [NSString stringWithFormat:@"amount=%@&currency=%@",amount,currency];
            CCTool *ccTool = [[CCTool alloc] init];


        NSLog(@"emcrpted data  skfjsf jakdfhjklfhjk%@",[ccTool encryptRSA:myRequestString key:rsaKey]);






            Happy Coding. :)