2 * Copyright (c) 2003-2007 Apple Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please
7 * obtain a copy of the License at http://www.apple.com/publicsource and
8 * read it before using this file.
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
12 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
13 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
15 * Please see the License for the specific language governing rights and
16 * limitations under the License.
20 * identPicker.h - Given a keychain, select from possible multiple
21 * SecIdentityRefs via stdio UI, and cook up a
22 * CFArray containing that identity and all certs needed
23 * for cert verification by an SSL peer. The resulting
24 * CFArrayRef is suitable for passing to SSLSetCertificate().
27 #ifndef _IDENT_PICKER_H_
28 #define _IDENT_PICKER_H_
30 #include <Security/Security.h>
31 #include <CoreFoundation/CoreFoundation.h>
38 * Get the final term of a keychain's path as a C string. Caller must free()
42 SecKeychainRef kcRef
);
45 * Obtain the printable name of a SecKeychainItemRef as a C string.
46 * Caller must free() the result.
48 char *kcItemPrintableName(
49 SecKeychainItemRef itemRef
);
52 * Obtain the final term of a keychain item's keychain path as a C string.
53 * Caller must free() the result.
54 * May well return NULL indicating the item has no keychain (e.g. az floating cert).
56 char *kcItemKcFileName(SecKeychainItemRef itemRef
);
60 * -- guaranteed no buffer overflow
61 * -- guaranteed NULL-terminated string
62 * -- handles empty string (i.e., response is just CR) properly
69 * IdentityPicker, returns full cert chain, optionally including root.
71 OSStatus
sslIdentPicker(
72 SecKeychainRef kc
, // NULL means use default list
73 SecCertificateRef trustedAnchor
, // optional additional trusted anchor
74 bool includeRoot
, // true --> root is appended to outArray
75 // false --> root not included
76 const CSSM_OID
*vfyPolicy
, // optional - if NULL, use SSL
77 CFArrayRef
*outArray
); // created and RETURNED
80 * Simple version, just returns a SecIdentityRef.
82 OSStatus
sslSimpleIdentPicker(
83 SecKeychainRef kc
, // NULL means use default list
84 SecIdentityRef
*ident
); // RETURNED
90 #endif /* _IDENT_PICKER_H_ */