2 * Copyright (c) 2002-2004,2011,2014 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@
25 // CertificateRequest.h
27 #ifndef _SECURITY_CERTIFICATEREQUEST_H_
28 #define _SECURITY_CERTIFICATEREQUEST_H_
30 #include <Security/SecCertificateRequest.h>
31 #include <security_utilities/seccfobject.h>
32 #include "SecCFTypes.h"
33 #include <security_utilities/alloc.h>
34 #include <security_cdsa_utilities/cssmdata.h>
35 #include <security_cdsa_client/tpclient.h>
36 #include <security_cdsa_client/clclient.h>
37 #include <security_utilities/debugging.h>
38 #include <CoreFoundation/CoreFoundation.h>
40 #define certReqDbg(args...) secdebug("certReq", ## args)
45 namespace KeychainCore
48 class CertificateRequest
: public SecCFObject
50 NOCOPY(CertificateRequest
)
52 SECCFFUNCTIONS(CertificateRequest
, SecCertificateRequestRef
, errSecInvalidItemRef
, gTypes().CertificateRequest
)
54 CertificateRequest(const CSSM_OID
&policy
,
55 CSSM_CERT_TYPE certificateType
,
56 CSSM_TP_AUTHORITY_REQUEST_TYPE requestType
,
57 SecKeyRef privateKeyItemRef
, // optional
58 SecKeyRef publicKeyItemRef
, // optional
59 const SecCertificateRequestAttributeList
*attributeList
,
61 * true when called from SecCertificateRequestCreate, cooking up a new
62 * request from scratch
63 * false when called from SecCertificateFindRequest, recomnstructing
64 * a request in progress
68 virtual ~CertificateRequest() throw();
71 sint32
*estimatedTime
);
73 sint32
*estimatedTime
, // optional
77 * Obtain policy/error specific return data blob. We own the data, it's
83 CSSM_CERT_TYPE
certType() { return mCertType
; }
84 CSSM_TP_AUTHORITY_REQUEST_TYPE
reqType() { return mReqType
; }
88 sint32
*estimatedTime
);
90 sint32
*estimatedTime
, // optional
92 void postPendingRequest();
94 /* preferences support */
95 CFStringRef
createUserKey();
96 CFStringRef
createPolicyKey();
97 CFDictionaryRef
getPolicyDictionary(
98 CFDictionaryRef prefsDict
);
99 CFDictionaryRef
getUserDictionary(
100 CFDictionaryRef policyDict
);
103 * Preferences storage and retrieval.
104 * Both assume valid mPolicy and mUserName. storeResults stores the
105 * specified data; retrieveResults retrieves whatever is found in the
106 * prefs dictionary and restores to mRefId or mCert as appropriate.
108 OSStatus
storeResults(
109 const CSSM_DATA
*refId
, // optional, for queued requests
110 const CSSM_DATA
*certDat
); // optional, for immediate completion
111 void retrieveResults();
112 void removeResults();
115 CRS_New
= 0, // created via SecCertificateRequestCreate
116 CRS_Reconstructed
, // created via SecCertificateFindRequest
117 CRS_HaveCert
, // completed request one way or another, have a good cert
118 CRS_HaveRefId
, // submitted request, have RefId for later retrieval
119 CRS_HaveOtherData
// submitted request, have other data in mRefId
125 CssmAutoData mPolicy
; /* i.e., "CssmAutoOid" */
126 CSSM_CERT_TYPE mCertType
;
127 CSSM_TP_AUTHORITY_REQUEST_TYPE mReqType
;
131 CssmAutoData mRefId
; /* returned from SubmitCredRequest() */
132 CertReqState mCertState
;
133 CssmAutoData mCertData
;
136 * The incoming SecCertificateRequestAttributeList oid/value pairs
139 CssmAutoData mUserName
;
140 CssmAutoData mPassword
; /* optional (lookup doesn't use it) */
141 CssmAutoData mHostName
; /* optional */
142 CssmAutoData mDomain
; /* optional */
144 bool mIsAsync
; /* true means no persistent state
145 * stored in user prefs; default
150 } // end namespace KeychainCore
152 } // end namespace Security
154 #endif // !_SECURITY_CERTIFICATEREQUEST_H_