Initial checkin. Passes tests on Mac and in iPhone simulator.
5 // Created by Jens Alfke on 3/26/09.
6 // Copyright 2009 Jens Alfke. All rights reserved.
9 #import "MYKeychainItem.h"
12 #import <Security/cssmtype.h>
18 /** An X.509 certificate. */
19 @interface MYCertificate : MYKeychainItem {
20 SecCertificateRef _certificateRef;
23 /** Creates a MYCertificate object for an existing Keychain certificate reference. */
24 - (id) initWithCertificateRef: (SecCertificateRef)certificateRef;
26 /** Creates a MYCertificate object from exported key data, but does not add it to any keychain. */
27 - (id) initWithCertificateData: (NSData*)data;
30 /** Creates a MYCertificate object from exported key data, but does not add it to any keychain. */
31 - (id) initWithCertificateData: (NSData*)data
32 type: (CSSM_CERT_TYPE) type
33 encoding: (CSSM_CERT_ENCODING) encoding;
36 /** The Keychain object reference for this key. */
37 @property (readonly) SecCertificateRef certificateRef;
39 /** The certificate's data. */
40 @property (readonly) NSData *certificateData;
42 /** The certificate's public key. */
43 @property (readonly) MYPublicKey *publicKey;
45 @property (readonly) NSString *commonName;
46 @property (readonly) NSArray *emailAddresses;
49 /** Finds the current 'preferred' certificate for the given name string. */
50 + (MYCertificate*) preferredCertificateForName: (NSString*)name;
52 /** Associates the receiver as the preferred certificate for the given name string. */
53 - (BOOL) setPreferredCertificateForName: (NSString*)name;