MYCertificate.h
author snej@snej.local
Sat Apr 04 20:42:03 2009 -0700 (2009-04-04)
changeset 0 0a6527af039b
child 1 60e4cbbb5128
permissions -rw-r--r--
Initial checkin. Passes tests on Mac and in iPhone simulator.
     1 //
     2 //  MYCertificate.h
     3 //  MYCrypto
     4 //
     5 //  Created by Jens Alfke on 3/26/09.
     6 //  Copyright 2009 Jens Alfke. All rights reserved.
     7 //
     8 
     9 #import "MYKeychainItem.h"
    10 
    11 #if !TARGET_OS_IPHONE
    12 #import <Security/cssmtype.h>
    13 #endif
    14 
    15 @class MYPublicKey;
    16 
    17 
    18 /** An X.509 certificate. */
    19 @interface MYCertificate : MYKeychainItem {
    20     SecCertificateRef _certificateRef;
    21 }
    22 
    23 /** Creates a MYCertificate object for an existing Keychain certificate reference. */
    24 - (id) initWithCertificateRef: (SecCertificateRef)certificateRef;
    25 
    26 /** Creates a MYCertificate object from exported key data, but does not add it to any keychain. */
    27 - (id) initWithCertificateData: (NSData*)data;
    28 
    29 #if !TARGET_OS_IPHONE
    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;
    34 #endif
    35 
    36 /** The Keychain object reference for this key. */
    37 @property (readonly) SecCertificateRef certificateRef;
    38 
    39 /** The certificate's data. */
    40 @property (readonly) NSData *certificateData;
    41 
    42 /** The certificate's public key. */
    43 @property (readonly) MYPublicKey *publicKey;
    44 
    45 @property (readonly) NSString *commonName;
    46 @property (readonly) NSArray *emailAddresses;
    47 
    48 #if !TARGET_OS_IPHONE
    49 /** Finds the current 'preferred' certificate for the given name string. */
    50 + (MYCertificate*) preferredCertificateForName: (NSString*)name;
    51 
    52 /** Associates the receiver as the preferred certificate for the given name string. */
    53 - (BOOL) setPreferredCertificateForName: (NSString*)name;
    54 #endif
    55 
    56 @end