LCCertificateChainProtocol.h

This file can be downloaded as part of milnlicence.tbz.

//
//  LCCertificateChainProtocol.h
//  LicenceCore - https://indie.miln.eu
//
//  Copyright © Graham Miln. All rights reserved. https://miln.eu
//
//  This package is subject to the terms of the Artistic License 2.0.
//  If a copy of the Artistic-2.0 was not distributed with this file, you can
//  obtain one at https://indie.miln.eu/licence

@import Foundation;

//NSString* LCCertificateChainServiceName = @"eu.miln.licence.xpc.certificate-chain";

@protocol LCCertificateChainProtocol

/** Return a complete certificate chain as an aggregate PEM block. */
- (void)certificateChainFor:(NSData*)pemData withReply:(void (^)(NSData*, NSError*))reply;

@end

/*
 To use the service from an application or other process, use NSXPCConnection to establish a connection to the service by doing something like this:

     _connectionToService = [[NSXPCConnection alloc] initWithServiceName:LCCertificateChainServiceName];
     _connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(LCCertificateChainProtocol)];
     [_connectionToService resume];

Once you have a connection to the service, you can use it like this:

     [[_connectionToService remoteObjectProxy] certificateChainFor:mySingleCertAsPEM withReply:^(NSData* inAggregatePEM, NSError* inError) {
         // We have received a response. Import the chain of certicates.
         NSLog(@"Result was: %@", pemChain);
     }];

 And, when you are finished with the service, clean up the connection like this:

     [_connectionToService invalidate];
*/