RNCryptor iOS PHP Fatal error: Uncaught exception 'Exception' with message 'Unsupported schema version 211'

571 views Asked by At

Can't find much documentation on this error...I think it has to do with clashing versions of RNCryptor...the RNCryptor version from iOS is clashing with my server-side RNCryptor-php version...I think.

Here is all the output from the error:

[Wed Dec 17 16:56:00 2014] [error] [client 192.168.1.3] PHP Fatal error: Uncaught exception 'Exception' with message 'Unsupported schema version 211' in /Library/WebServer/Documents/lib/RNCryptor/Cryptor.php:70\nStack trace:\n#0 /Library/WebServer/Documents/lib/RNCryptor/Decryptor.php(66): RNCryptor\\Cryptor->_configureSettings(211)\n#1 /Library/WebServer/Documents/lib/RNCryptor/Decryptor.php(49): RNCryptor\\Decryptor->_parseHeaders('\\xD3}5\\xEBN\\xFB\\xD1\\xDD\\xBA\\xF5\\xD6\\xF6s\\xB7:...')\n#2 /Library/WebServer/Documents/lib/RNCryptor/Decryptor.php(22): RNCryptor\\Decryptor->_unpackEncryptedBase64Data('<03016077 0d269...')\n#3 /Library/WebServer/Documents/accessy/index.php(120): RNCryptor\\Decryptor->decrypt('<03016077 0d269...', 'AwEOM//0tNskVvC...')\n#4 /Library/WebServer/Documents/accessy/index.php(189): Auth->auth('AwEOM//0tNskVvC...', false)\n#5 {main}\n thrown in /Library/WebServer/Documents/lib/RNCryptor/Cryptor.php on line 70

I'm hoping someone can look at that and just tell me whats wrong. I have tried v2.0 and v2.1 on the iOS side and it looks like there is only one version for RNCryptor-php...I guess I could try v1.0/etc. but I'm guessing those versions are inherently less secure being that they are older. Anyone have any ideas?

This is my iOS encryption code that RNCryptor-php seems to not be able to handle for some reason:

NSData *what1 = [emailcurrent dataUsingEncoding:NSUTF8StringEncoding];

NSError *errory5;

NSData *useremaily = [RNEncryptor encryptData:what1 withSettings:kRNCryptorAES256Settings password:@"xxxxx" error:&errory5];`

I'm still not sure about one thing actually, I have tried a few different things...but as of right now...I am sending useremaily along with the request (not converting it to a string or anything) as the POST data...I think this is correct.

Then I use NSURLConnection in the way I think I should be, and the connection happens and executes but I always get the above error in the PHP error log.

Any ideas would be greatly appreciated.

1

There are 1 answers

0
ewizard On

Wow - so it took me the past few days...all the way up until the point that I decided to include the NSURLConnection code in my question. This is what it was:

NSString *post = [NSString stringWithFormat:@"email=%@", useremaily];

NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://192.168.1.10/accessy/index.php"]]];

[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];

self.connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];`

The line that I think was messing everything up was:

NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

I changed it to:

NSData *postData = [[NSData alloc] initWithBase64EncodedString:post options:0];

It actually still isn't working how I want it to...but this resolved that error incase anyone has this problem specifically. Might have to ask another question for what I'm dealing with now...but I guess if you want to comment about the process in general (iOS to PHP with RNCryptor) - that might still be helpful. Thanks.