2 * Copyright (c) 2008-2009 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 * SecTrustServer.h - certificate trust evaluation engine
25 * Created by Michael Brouwer on 12/12/08.
29 #ifndef _SECURITY_SECTRUSTSERVER_H_
30 #define _SECURITY_SECTRUSTSERVER_H_
32 #include <CoreFoundation/CFString.h>
34 #include <Security/SecCertificatePath.h>
35 #include <Security/SecTrust.h>
36 #include <Security/SecBasePriv.h> /* For errSecWaitForCallback. */
37 #include <mach/port.h>
40 #if defined(__cplusplus)
46 #define kSecTrustCertificatesKey CFSTR("certificates")
47 #define kSecTrustAnchorsKey CFSTR("anchors")
48 #define kSecTrustAnchorsOnlyKey CFSTR("anchorsOnly")
49 #define kSecTrustPoliciesKey CFSTR("policies")
50 #define kSecTrustVerifyDateKey CFSTR("verifyDate")
53 #define kSecTrustDetailsKey CFSTR("details")
54 #define kSecTrustChainKey CFSTR("chain")
55 #define kSecTrustResultKey CFSTR("result")
56 #define kSecTrustInfoKey CFSTR("info")
58 typedef struct SecPathBuilder
*SecPathBuilderRef
;
60 /* Completion callback. You should call SecTrustSessionDestroy from this. */
61 typedef void(*SecPathBuilderCompleted
)(const void *userData
,
62 SecCertificatePathRef chain
, CFArrayRef details
, CFDictionaryRef info
,
63 SecTrustResultType result
);
65 /* Returns a new trust path builder and policy evaluation engine instance. */
66 SecPathBuilderRef
SecPathBuilderCreate(CFArrayRef certificates
,
67 CFArrayRef anchors
, bool anchorsOnly
, CFArrayRef policies
,
68 CFAbsoluteTime verifyTime
,
69 SecPathBuilderCompleted completed
, const void *userData
);
71 /* Returns true if it's ok to perform network operations for this builder. */
72 bool SecPathBuilderCanAccessNetwork(SecPathBuilderRef builder
);
74 /* Disable or enable network access for this builder if allow is false
75 network access will be disabled. */
76 void SecPathBuilderSetCanAccessNetwork(SecPathBuilderRef builder
, bool allow
);
78 /* Core of the trust evaluation engine, this will invoke the completed
79 callback and return false if the evaluation completed, or return true if
80 the evaluation is still waiting for some external event (usually the
82 bool SecPathBuilderStep(SecPathBuilderRef builder
);
85 /* Returns noErr if the operation has completed synchronously. Returns
86 errSecWaitForCallback if the operation is running in the background. Can
87 also return paramErr if one or more of the inputs aren't correct. Upon
88 completion the completed callback is called. */
89 OSStatus
SecTrustServerEvaluateAsync(CFDictionaryRef args_in
,
90 SecPathBuilderCompleted completed
, const void *userData
);
92 /* Synchronously invoke SecTrustServerEvaluateAsync. */
93 OSStatus
SecTrustServerEvaluate(CFDictionaryRef args_in
, CFTypeRef
*args_out
);
95 #if defined(__cplusplus)
99 #endif /* !_SECURITY_SECTRUSTSERVER_H_ */