Author Message
prashant06
Joined: Aug 8, 2017
Messages: 32
Offline
I am new to CSDK, in sample app they used the Platform Trust Store but when i have certificate where to kept in code and how to install on device. what changes I needed given in sample code
CSSecurityPolicyConfiguration *securityPolicyConfig = [[CSSecurityPolicyConfiguration alloc] init];

securityPolicyConfig.continueOnTLSServerIdentityFailure = YES;

securityPolicyConfig.revocationCheckPolicy = CSSecurityPolicyBestEffort;
Artem.Tsarev
Joined: Jul 13, 2016
Messages: 48
Offline
Hello,

Have you tried to access Avaya Client SDK Communication Package documentation at https://www.devconnectprogram.com/site/global/products_resources/avaya_client_sdk/programming_docs/current/ios/communication/index.gsp?

It has a lot of guides and technical articles for you to learn about the SDK. It might happen that what you are looking for is explained in https://www.devconnectprogram.com/site/global/products_resources/avaya_client_sdk/programming_docs/current/ios/communication/tech/working_certificates.gsp

Best regards,
Artem Tsarev.
prashant06
Joined: Aug 8, 2017
Messages: 32
Offline
I have tried this but not working. Can you tell where i am going wrong?
NSError *error;
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"avaya_cer"
ofType:@"crt"];

// Instantiate a list of certificates.
NSMutableArray* trustedAnchors = [[NSMutableArray alloc] init];
// Populate CA Certificates in the trustedAnchors as required.
[trustedAnchors addObject:filePath];

[self.client.certificateManager setCertificates:trustedAnchors error:&error];
NSLog(@"Certificate Error %@", error);


I am getting "Certificate store error"
Pavel_K
Joined: Dec 20, 2016
Messages: 67
Offline
1. You need to enable Private trust store:


CSSecurityPolicyConfiguration *securityPolicyConfig =
[[CSSecurityPolicyConfiguration alloc] init];
securityPolicyConfig.privateTrustStoreEnabled = true;


2. You should add content of the cert in base64 format (not file path) to "trustedAnchors" array.
You can use "dataWithContentsOfURL" iOS method.


NSData *certificate = [NSData dataWithContentsOfURL: docFile.url
options: NSDataReadingUncached
error: &error];
prashant06
Joined: Aug 8, 2017
Messages: 32
Offline
I have tried this

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSData *certificate = [NSData dataWithContentsOfURL: fileURL
options: NSDataReadingUncached
error: &error];

NSString* base64String = [certificate base64EncodedStringWithOptions:0];
NSMutableArray* trustedAnchors = [[NSMutableArray alloc] init];
// Populate CA Certificates in the trustedAnchors as required.
[trustedAnchors addObject:base64String];
[self.client.certificateManager setCertificates:trustedAnchors error:&error];

but still getting error. Can you please tell how populate trustedAnchors array?
Pavel_K
Joined: Dec 20, 2016
Messages: 67
Offline
Certificate with "crt" extension already contains base64 string. Try to use "certificate" object in "trustedAnchors" array.
prashant06
Joined: Aug 8, 2017
Messages: 32
Offline
I have tried what you mentioned

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSData *certificate = [NSData dataWithContentsOfURL: fileURL
options: NSDataReadingUncached
error: &error];
NSMutableArray* trustedAnchors = [[NSMutableArray alloc] init];
// Populate CA Certificates in the trustedAnchors as required.
[trustedAnchors addObject:certificate];
[self.client.certificateManager setCertificates:trustedAnchors error:&error];
NSLog(@"Certificate Error %@", error);

after this i am getting '-[NSConcreteData UTF8String]: unrecognized selector sent to instance 0x17f52eb0' this error.
Pavel_K
Joined: Dec 20, 2016
Messages: 67
Offline
Otherwise you can use pem certificate and create parser for it like this:


- (NSArray*)parsePemCertificates: (NSData*) data
{
static NSString * const startCertificate = @"-----BEGIN CERTIFICATE-----";
static NSString * const endCertificate = @"-----END CERTIFICATE-----";

NSMutableArray* certificates = [[NSMutableArray alloc] init];

NSString* content = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSScanner *scanner = [NSScanner scannerWithString: content];

while (YES)
{

NSString *certificate;
[scanner scanUpToString: startCertificate intoString:nil];
[scanner scanUpToString: endCertificate intoString: &certificate];
if (!certificate) {
break;
}

certificate = [certificate stringByAppendingString:endCertificate];
NSLog(@"Parsed certificate %@", certificate);
[certificates addObject:certificate];

}

return certificates;
}
prashant06
Joined: Aug 8, 2017
Messages: 32
Offline
Thanks lot Pavel_k. You saved my day. :)
Go to:   
Mobile view