* Some cleanup. Got the test cases to pass again.
* Added some missing copyright notices.
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 {
21 SecCertificateRef _certificateRef;
24 /** Creates a MYCertificate object for an existing Keychain certificate reference. */
25 + (MYCertificate*) certificateWithCertificateRef: (SecCertificateRef)certificateRef;
27 /** Initializes a MYCertificate object for an existing Keychain certificate reference. */
28 - (id) initWithCertificateRef: (SecCertificateRef)certificateRef;
30 /** Creates a MYCertificate object from exported key data, but does not add it to any keychain. */
31 - (id) initWithCertificateData: (NSData*)data;
33 /** Checks whether two MYCertificate objects have bit-for-bit identical certificate data. */
34 - (BOOL)isEqualToCertificate:(MYCertificate*)cert;
36 /** The Keychain object reference for this certificate. */
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 /** The name of the subject (owner) of the certificate. */
46 @property (readonly) NSString *commonName;
50 * Functionality not available on iPhone.
55 /** Creates a MYCertificate object from exported key data, but does not add it to any keychain. */
56 - (id) initWithCertificateData: (NSData*)data
57 type: (CSSM_CERT_TYPE) type
58 encoding: (CSSM_CERT_ENCODING) encoding;
60 /** The list (if any) of the subject's email addresses. */
61 @property (readonly) NSArray *emailAddresses;
63 /** Finds the current 'preferred' certificate for the given name string. */
64 + (MYCertificate*) preferredCertificateForName: (NSString*)name;
66 /** Associates the receiver as the preferred certificate for the given name string. */
67 - (BOOL) setPreferredCertificateForName: (NSString*)name;
78 + (SecPolicyRef) X509Policy;
79 + (SecPolicyRef) SSLPolicy;
80 + (SecPolicyRef) SMIMEPolicy;
81 - (CSSM_CERT_TYPE) certificateType;
82 - (NSArray*) trustSettings;
83 - (BOOL) setUserTrust: (SecTrustUserSetting)trustSetting;
91 NSString* MYPolicyGetName( SecPolicyRef policy );
92 NSString* MYTrustDescribe( SecTrustRef trust );
93 NSString* MYTrustResultDescribe( SecTrustResultType result );