MYCertificate.h
author snej@snej.local
Sat Apr 04 22:56:13 2009 -0700 (2009-04-04)
changeset 1 60e4cbbb5128
parent 0 0a6527af039b
child 2 8982b8fada63
permissions -rw-r--r--
Code cleanup, more header comments.
     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     @private
    21     SecCertificateRef _certificateRef;
    22 }
    23 
    24 /** Creates a MYCertificate object for an existing Keychain certificate reference. */
    25 - (id) initWithCertificateRef: (SecCertificateRef)certificateRef;
    26 
    27 /** Creates a MYCertificate object from exported key data, but does not add it to any keychain. */
    28 - (id) initWithCertificateData: (NSData*)data;
    29 
    30 #if !TARGET_OS_IPHONE
    31 /** Creates a MYCertificate object from exported key data, but does not add it to any keychain. */
    32 - (id) initWithCertificateData: (NSData*)data
    33                           type: (CSSM_CERT_TYPE) type
    34                       encoding: (CSSM_CERT_ENCODING) encoding;
    35 #endif
    36 
    37 /** The Keychain object reference for this certificate. */
    38 @property (readonly) SecCertificateRef certificateRef;
    39 
    40 /** The certificate's data. */
    41 @property (readonly) NSData *certificateData;
    42 
    43 /** The certificate's public key. */
    44 @property (readonly) MYPublicKey *publicKey;
    45 
    46 /** The name of the subject (owner) of the certificate. */
    47 @property (readonly) NSString *commonName;
    48 
    49 #if !TARGET_OS_IPHONE
    50 /** The list (if any) of the subject's email addresses. */
    51 @property (readonly) NSArray *emailAddresses;
    52 
    53 /** Finds the current 'preferred' certificate for the given name string. */
    54 + (MYCertificate*) preferredCertificateForName: (NSString*)name;
    55 
    56 /** Associates the receiver as the preferred certificate for the given name string. */
    57 - (BOOL) setPreferredCertificateForName: (NSString*)name;
    58 #endif
    59 
    60 @end