2 * Copyright (c) 2002-2016 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 @header SecCertificate
26 The functions provided in SecCertificate.h implement and manage a
27 particular type of keychain item that represents a X.509 public key
28 certificate. You can store a certificate in a keychain, but a
29 certificate can also be a transient object.
31 You can use a certificate as a keychain item in most functions.
34 #ifndef _SECURITY_SECCERTIFICATE_H_
35 #define _SECURITY_SECCERTIFICATE_H_
37 #include <CoreFoundation/CFBase.h>
38 #include <CoreFoundation/CFArray.h>
39 #include <CoreFoundation/CFData.h>
40 #include <CoreFoundation/CFDate.h>
41 #include <CoreFoundation/CFError.h>
42 #include <Availability.h>
43 #include <AvailabilityMacros.h>
45 #include <Security/SecBase.h>
48 #define _SECURITY_VERSION_GREATER_THAN_57610_
50 #include <Security/cssmtype.h>
51 #include <Security/x509defs.h>
56 CF_ASSUME_NONNULL_BEGIN
57 CF_IMPLICIT_BRIDGING_ENABLED
60 @function SecCertificateGetTypeID
61 @abstract Returns the type identifier of SecCertificate instances.
62 @result The CFTypeID of SecCertificate instances.
64 CFTypeID
SecCertificateGetTypeID(void)
65 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_2_0
);
68 @function SecCertificateCreateWithData
69 @abstract Create a certificate given it's DER representation as a CFData.
70 @param allocator CFAllocator to allocate the certificate with.
71 @param data DER encoded X.509 certificate.
72 @result Return NULL if the passed-in data is not a valid DER-encoded
73 X.509 certificate, return a SecCertificateRef otherwise.
76 SecCertificateRef
SecCertificateCreateWithData(CFAllocatorRef __nullable allocator
, CFDataRef data
)
77 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_2_0
);
80 @function SecCertificateCopyData
81 @abstract Return the DER representation of an X.509 certificate.
82 @param certificate SecCertificate object created with
83 SecCertificateCreateWithData().
84 @result DER encoded X.509 certificate.
86 CFDataRef
SecCertificateCopyData(SecCertificateRef certificate
)
87 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_2_0
);
90 @function SecCertificateCopySubjectSummary
91 @abstract Return a simple string which hopefully represents a human
92 understandable summary.
93 @param certificate A reference to the certificate from which to derive
94 the subject summary string.
95 @discussion All the data in this string comes from the certificate itself
96 and thus it's in whatever language the certificate itself is in.
97 @result A CFStringRef which the caller should CFRelease() once it's no
101 CFStringRef
SecCertificateCopySubjectSummary(SecCertificateRef certificate
)
102 __OSX_AVAILABLE_STARTING(__MAC_10_6
, __IPHONE_2_0
);
105 @function SecCertificateCopyCommonName
106 @abstract Retrieves the common name of the subject of a given certificate.
107 @param certificate A reference to the certificate from which to retrieve the common name.
108 @param commonName On return, a reference to the common name. Your code must release this reference by calling the CFRelease function.
109 @result A result code. See "Security Error Codes" (SecBase.h).
110 @discussion All the data in this string comes from the certificate itself, and thus it's in whatever language the certificate itself is in.
111 Note that the certificate's common name field may not be present, or may be inadequate to describe the certificate; for display purposes,
112 you should consider using SecCertificateCopySubjectSummary instead of this function.
114 OSStatus
SecCertificateCopyCommonName(SecCertificateRef certificate
, CFStringRef
* __nonnull CF_RETURNS_RETAINED commonName
)
115 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_10_3
);
118 @function SecCertificateCopyEmailAddresses
119 @abstract Returns an array of zero or more email addresses for the subject of a given certificate.
120 @param certificate A reference to the certificate from which to retrieve the email addresses.
121 @param emailAddresses On return, an array of zero or more CFStringRef elements corresponding to each email address found.
122 Your code must release this array reference by calling the CFRelease function.
123 @result A result code. See "Security Error Codes" (SecBase.h).
125 OSStatus
SecCertificateCopyEmailAddresses(SecCertificateRef certificate
, CFArrayRef
* __nonnull CF_RETURNS_RETAINED emailAddresses
)
126 __OSX_AVAILABLE_STARTING(__MAC_10_5
, __IPHONE_10_3
);
129 @function SecCertificateCopyNormalizedIssuerSequence
130 @abstract Return the certificate's normalized issuer
131 @param certificate The certificate from which to get values
132 @discussion The issuer is a sequence in the format used by SecItemCopyMatching. The content returned is a DER-encoded X.509 distinguished name. For a display version of the issuer, call SecCertificateCopyValues. The caller must CFRelease the value returned.
135 CFDataRef
SecCertificateCopyNormalizedIssuerSequence(SecCertificateRef certificate
)
136 __OSX_AVAILABLE_STARTING(__MAC_10_12_4
, __IPHONE_10_3
);
139 @function SecCertificateCopyNormalizedSubjectSequence
140 @abstract Return the certificate's normalized subject
141 @param certificate The certificate from which to get values
142 @discussion The subject is a sequence in the format used by SecItemCopyMatching. The content returned is a DER-encoded X.509 distinguished name. For a display version of the subject, call SecCertificateCopyValues. The caller must CFRelease the value returned.
145 CFDataRef
SecCertificateCopyNormalizedSubjectSequence(SecCertificateRef certificate
)
146 __OSX_AVAILABLE_STARTING(__MAC_10_12_4
, __IPHONE_10_3
);
150 @function SecCertificateCopyPublicKey
151 @abstract Retrieves the public key for a given certificate.
152 @param certificate A reference to the certificate from which to retrieve the public key.
153 @result A reference to the public key for the specified certificate. Your code must release this reference by calling the CFRelease function.
156 SecKeyRef
SecCertificateCopyPublicKey(SecCertificateRef certificate
)
157 __OSX_AVAILABLE_STARTING(__MAC_NA
, __IPHONE_10_3
);
162 @function SecCertificateCopyPublicKey
163 @abstract Retrieves the public key for a given certificate.
164 @param certificate A reference to the certificate from which to retrieve the public key.
165 @param key On return, a reference to the public key for the specified certificate. Your code must release this reference by calling the CFRelease function.
166 @result A result code. See "Security Error Codes" (SecBase.h).
168 OSStatus
SecCertificateCopyPublicKey(SecCertificateRef certificate
, SecKeyRef
* __nonnull CF_RETURNS_RETAINED key
)
169 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
174 @function SecCertificateCopySerialNumber
175 @abstract Return the certificate's serial number.
176 @param certificate The certificate from which to get values
177 @discussion Return the content of a DER-encoded integer (without the tag and length fields) for this certificate's serial number. The caller must CFRelease the value returned.
180 CFDataRef
SecCertificateCopySerialNumber(SecCertificateRef certificate
)
181 __OSX_AVAILABLE_STARTING(__MAC_NA
, __IPHONE_10_3
);
186 @function SecCertificateCopySerialNumber
187 @abstract Return the certificate's serial number.
188 @param certificate The certificate from which to get values
189 @param error An optional pointer to a CFErrorRef. This value is set if an error occurred. If not NULL the caller is responsible for releasing the CFErrorRef.
190 @discussion Return the content of a DER-encoded integer (without the tag and length fields) for this certificate's serial number. The caller must CFRelease the value returned.
193 CFDataRef
SecCertificateCopySerialNumber(SecCertificateRef certificate
, CFErrorRef
*error
)
194 __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
198 * Legacy functions (OS X only)
202 @enum CertificateItemAttributes
203 @abstract Indicates the type of a certificate item attribute.
204 @constant kSecSubjectItemAttr Indicates a DER-encoded subject distinguished name.
205 @constant kSecIssuerItemAttr Indicates a DER-encoded issuer distinguished name.
206 @constant kSecSerialNumberItemAttr Indicates a DER-encoded certificate serial number (without the tag and length).
207 @constant kSecPublicKeyHashItemAttr Indicates a public key hash.
208 @constant kSecSubjectKeyIdentifierItemAttr Indicates a subject key identifier.
209 @constant kSecCertTypeItemAttr Indicates a certificate type.
210 @constant kSecCertEncodingItemAttr Indicates a certificate encoding.
214 kSecSubjectItemAttr
= 'subj',
215 kSecIssuerItemAttr
= 'issu',
216 kSecSerialNumberItemAttr
= 'snbr',
217 kSecPublicKeyHashItemAttr
= 'hpky',
218 kSecSubjectKeyIdentifierItemAttr
= 'skid',
219 kSecCertTypeItemAttr
= 'ctyp',
220 kSecCertEncodingItemAttr
= 'cenc'
221 } /*DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER*/;
223 #pragma mark ---- Certificate Operations ----
226 @function SecCertificateCreateFromData
227 @abstract Creates a certificate based on the input data, type, and encoding.
228 @param data A pointer to the certificate data.
229 @param type The certificate type as defined in cssmtype.h.
230 @param encoding The certificate encoding as defined in cssmtype.h.
231 @param certificate On return, a reference to the newly created certificate.
232 @result A result code. See "Security Error Codes" (SecBase.h).
233 @discussion This API is deprecated in 10.7 Please use the SecCertificateCreateWithData API instead.
235 OSStatus
SecCertificateCreateFromData(const CSSM_DATA
*data
, CSSM_CERT_TYPE type
, CSSM_CERT_ENCODING encoding
, SecCertificateRef
* __nonnull CF_RETURNS_RETAINED certificate
)
236 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
239 @function SecCertificateAddToKeychain
240 @abstract Adds a certificate to the specified keychain.
241 @param certificate A reference to a certificate.
242 @param keychain A reference to the keychain in which to add the certificate. Pass NULL to add the certificate to the default keychain.
243 @result A result code. See "Security Error Codes" (SecBase.h).
244 @discussion This function is successful only if the certificate was created using the SecCertificateCreateFromData or
245 SecCertificateCreateWithData functions, and the certificate has not yet been added to the specified keychain.
247 OSStatus
SecCertificateAddToKeychain(SecCertificateRef certificate
, SecKeychainRef __nullable keychain
)
248 __OSX_AVAILABLE_STARTING(__MAC_10_3
, __IPHONE_NA
);
251 @function SecCertificateGetData
252 @abstract Retrieves the data for a given certificate.
253 @param certificate A reference to the certificate from which to retrieve the data.
254 @param data On return, the CSSM_DATA structure pointed to by data is filled in. You must allocate the space for a CSSM_DATA structure before calling this function. This data pointer is only guaranteed to remain valid as long as the certificate remains unchanged and valid.
255 @result A result code. See "Security Error Codes" (SecBase.h).
256 @discussion This API is deprecated in 10.7. Please use the SecCertificateCopyData API instead.
258 OSStatus
SecCertificateGetData(SecCertificateRef certificate
, CSSM_DATA_PTR data
)
259 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
262 @function SecCertificateGetType
263 @abstract Retrieves the type for a given certificate.
264 @param certificate A reference to the certificate from which to obtain the type.
265 @param certificateType On return, the certificate type of the certificate. Certificate types are defined in cssmtype.h.
266 @result A result code. See "Security Error Codes" (SecBase.h).
267 @discussion This API is deprecated in 10.7. Please use the SecCertificateCopyValues API instead.
269 OSStatus
SecCertificateGetType(SecCertificateRef certificate
, CSSM_CERT_TYPE
*certificateType
)
270 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
273 @function SecCertificateGetSubject
274 @abstract Retrieves the subject name for a given certificate.
275 @param certificate A reference to the certificate from which to obtain the subject name.
276 @param subject On return, a pointer to a CSSM_X509_NAME struct which contains the subject's X.509 name (x509defs.h). This pointer remains valid until the certificate reference is released. The caller should not attempt to free this pointer.
277 @result A result code. See "Security Error Codes" (SecBase.h).
278 @discussion Prior to Mac OS X 10.5, this function did not return any output in the subject parameter. Your code should check the returned pointer value (in addition to the function result) before attempting to use it.
280 const CSSM_X509_NAME *subject = NULL;
281 OSStatus status = SecCertificateGetSubject(certificate, &subject);
282 if ( (status == errSecSuccess) && (subject != NULL) ) {
285 This API is deprecated in 10.7. Please use the SecCertificateCopyValues API instead.
287 OSStatus
SecCertificateGetSubject(SecCertificateRef certificate
, const CSSM_X509_NAME
* __nullable
* __nonnull subject
)
288 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
291 @function SecCertificateGetIssuer
292 @abstract Retrieves the issuer name for a given certificate.
293 @param certificate A reference to the certificate from which to obtain the issuer name.
294 @param issuer On return, a pointer to a CSSM_X509_NAME struct which contains the issuer's X.509 name (x509defs.h). This pointer remains valid until the certificate reference is released. The caller should not attempt to free this pointer.
295 @result A result code. See "Security Error Codes" (SecBase.h).
296 @discussion Prior to Mac OS X 10.5, this function did not return any output in the issuer parameter. Your code should check the returned pointer value (in addition to the function result) before attempting to use it.
298 const CSSM_X509_NAME *issuer = NULL;
299 OSStatus status = SecCertificateGetIssuer(certificate, &issuer);
300 if ( (status == errSecSuccess) && (issuer != NULL) ) {
303 This API is deprecated in 10.7. Please use the SecCertificateCopyValues API instead.
305 OSStatus
SecCertificateGetIssuer(SecCertificateRef certificate
, const CSSM_X509_NAME
* __nullable
* __nonnull issuer
)
306 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
309 @function SecCertificateGetCLHandle
310 @abstract Retrieves the certificate library handle for a given certificate.
311 @param certificate A reference to the certificate from which to obtain the certificate library handle.
312 @param clHandle On return, the certificate library handle of the given certificate. This handle remains valid at least as long as the certificate does.
313 @result A result code. See "Security Error Codes" (SecBase.h).
314 @discussion This API is deprecated in 10.7. Please use the SecCertificateCopyValues API instead.
316 OSStatus
SecCertificateGetCLHandle(SecCertificateRef certificate
, CSSM_CL_HANDLE
*clHandle
)
317 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
320 @function SecCertificateGetAlgorithmID
321 @abstract Retrieves the algorithm identifier for a given certificate.
322 @param certificate A reference to the certificate from which to retrieve the algorithm identifier.
323 @param algid On return, a pointer to a CSSM_X509_ALGORITHM_IDENTIFIER struct which identifies the algorithm for this certificate (x509defs.h). This pointer remains valid until the certificate reference is released. The caller should not attempt to free this pointer.
324 @result A result code. See "Security Error Codes" (SecBase.h).
325 discussion This API is deprecated in 10.7. Please use the SecCertificateCopyValues API instead.
327 OSStatus
SecCertificateGetAlgorithmID(SecCertificateRef certificate
, const CSSM_X509_ALGORITHM_IDENTIFIER
* __nullable
* __nonnull algid
)
328 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
331 @function SecCertificateCopyPreference
332 @abstract Returns the preferred certificate for the specified name and key usage. If a preferred certificate does not exist for the specified name and key usage, NULL is returned.
333 @param name A string containing an email address (RFC822) or other name for which a preferred certificate is requested.
334 @param keyUsage A CSSM_KEYUSE key usage value, as defined in cssmtype.h. Pass 0 to ignore this parameter.
335 @param certificate On return, a reference to the preferred certificate, or NULL if none was found. You are responsible for releasing this reference by calling the CFRelease function.
336 @result A result code. See "Security Error Codes" (SecBase.h).
337 @discussion This function will typically be used to obtain the preferred encryption certificate for an email recipient.
338 This API is deprecated in 10.7. Please use the SecCertificateCopyPreferred API instead.
340 OSStatus
SecCertificateCopyPreference(CFStringRef name
, uint32 keyUsage
, SecCertificateRef
* __nonnull CF_RETURNS_RETAINED certificate
)
341 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
344 @function SecCertificateCopyPreferred
345 @abstract Returns the preferred certificate for the specified name and key usage. If a preferred certificate does not exist for the specified name and key usage, NULL is returned.
346 @param name A string containing an email address (RFC822) or other name for which a preferred certificate is requested.
347 @param keyUsage A CFArrayRef value, containing items defined in SecItem.h Pass NULL to ignore this parameter. (kSecAttrCanEncrypt, kSecAttrCanDecrypt, kSecAttrCanDerive, kSecAttrCanSign, kSecAttrCanVerify, kSecAttrCanWrap, kSecAttrCanUnwrap)
348 @result On return, a reference to the preferred certificate, or NULL if none was found. You are responsible for releasing this reference by calling the CFRelease function.
349 @discussion This function will typically be used to obtain the preferred encryption certificate for an email recipient. If a preferred certificate has not been set
350 for the supplied name, the returned reference will be NULL. Your code should then perform a search for possible certificates, using the SecItemCopyMatching API.
353 SecCertificateRef
SecCertificateCopyPreferred(CFStringRef name
, CFArrayRef __nullable keyUsage
)
354 __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
357 @function SecCertificateSetPreference
358 @abstract Sets the preferred certificate for a specified name, key usage, and date.
359 @param certificate A reference to the certificate which will be preferred.
360 @param name A string containing an email address (RFC822) or other name for which a preferred certificate will be associated.
361 @param keyUsage A CSSM_KEYUSE key usage value, as defined in cssmtype.h. Pass 0 to avoid specifying a particular key usage.
362 @param date (optional) A date reference. If supplied, the preferred certificate will be changed only if this date is later than the currently saved setting. Pass NULL if this preference should not be restricted by date.
363 @result A result code. See "Security Error Codes" (SecBase.h).
364 @discussion This function will typically be used to set the preferred encryption certificate for an email recipient, either manually (when encrypting email to a recipient) or automatically upon receipt of encrypted email.
365 This API is deprecated in 10.7. Plese use the SecCertificateSetPreferred API instead.
367 OSStatus
SecCertificateSetPreference(SecCertificateRef certificate
, CFStringRef name
, uint32 keyUsage
, CFDateRef __nullable date
)
368 DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
;
371 @function SecCertificateSetPreferred
372 @abstract Sets the preferred certificate for a specified name and optional key usage.
373 @param certificate A reference to the preferred certificate. If NULL is passed, any existing preference for the specified name is cleared instead.
374 @param name A string containing an email address (RFC822) or other name for which a preferred certificate will be associated.
375 @param keyUsage A CFArrayRef value, containing items defined in SecItem.h Pass NULL to ignore this parameter. (kSecAttrCanEncrypt, kSecAttrCanDecrypt, kSecAttrCanDerive, kSecAttrCanSign, kSecAttrCanVerify, kSecAttrCanWrap, kSecAttrCanUnwrap)
376 @result A result code. See "Security Error Codes" (SecBase.h).
377 @discussion This function will typically be used to set the preferred encryption certificate for an email recipient, either manually (when encrypting email to a recipient)
378 or automatically upon receipt of encrypted email.
380 OSStatus
SecCertificateSetPreferred(SecCertificateRef __nullable certificate
, CFStringRef name
, CFArrayRef __nullable keyUsage
)
381 __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
385 @abstract Flags to indicate key usages in the KeyUsage extension of a certificate
386 @constant kSecKeyUsageUnspecified No KeyUsage extension in certificate.
387 @constant kSecKeyUsageDigitalSignature DigitalSignature bit set in KeyUsage extension.
388 @constant kSecKeyUsageNonRepudiation NonRepudiation bit set in KeyUsage extension.
389 @constant kSecKeyUsageContentCommitment ContentCommitment bit set in KeyUsage extension.
390 @constant kSecKeyUsageKeyEncipherment KeyEncipherment bit set in KeyUsage extension.
391 @constant kSecKeyUsageDataEncipherment DataEncipherment bit set in KeyUsage extension.
392 @constant kSecKeyUsageKeyAgreement KeyAgreement bit set in KeyUsage extension.
393 @constant kSecKeyUsageKeyCertSign KeyCertSign bit set in KeyUsage extension.
394 @constant kSecKeyUsageCRLSign CRLSign bit set in KeyUsage extension.
395 @constant kSecKeyUsageEncipherOnly EncipherOnly bit set in KeyUsage extension.
396 @constant kSecKeyUsageDecipherOnly DecipherOnly bit set in KeyUsage extension.
397 @constant kSecKeyUsageCritical KeyUsage extension is marked critical.
398 @constant kSecKeyUsageAll For masking purposes, all SecKeyUsage values.
400 typedef CF_OPTIONS(uint32_t, SecKeyUsage
) {
401 kSecKeyUsageUnspecified
= 0u,
402 kSecKeyUsageDigitalSignature
= 1u << 0,
403 kSecKeyUsageNonRepudiation
= 1u << 1,
404 kSecKeyUsageContentCommitment
= 1u << 1,
405 kSecKeyUsageKeyEncipherment
= 1u << 2,
406 kSecKeyUsageDataEncipherment
= 1u << 3,
407 kSecKeyUsageKeyAgreement
= 1u << 4,
408 kSecKeyUsageKeyCertSign
= 1u << 5,
409 kSecKeyUsageCRLSign
= 1u << 6,
410 kSecKeyUsageEncipherOnly
= 1u << 7,
411 kSecKeyUsageDecipherOnly
= 1u << 8,
412 kSecKeyUsageCritical
= 1u << 31,
413 kSecKeyUsageAll
= 0x7FFFFFFFu
417 @enum kSecPropertyKey
418 @abstract Constants used to access dictionary entries returned by SecCertificateCopyValues
419 @constant kSecPropertyKeyType The type of the entry
420 @constant kSecPropertyKeyLabel The label of the entry
421 @constant kSecPropertyKeyLocalizedLabel The localized label of the entry
422 @constant kSecPropertyKeyValue The value of the entry
425 extern const CFStringRef kSecPropertyKeyType
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
426 extern const CFStringRef kSecPropertyKeyLabel
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
427 extern const CFStringRef kSecPropertyKeyLocalizedLabel
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
428 extern const CFStringRef kSecPropertyKeyValue
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
431 @enum kSecPropertyType
432 @abstract Public Constants for property list values returned by SecCertificateCopyValues
433 @discussion Note that kSecPropertyTypeTitle and kSecPropertyTypeError are defined in SecTrust.h
435 extern const CFStringRef kSecPropertyTypeWarning
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
436 extern const CFStringRef kSecPropertyTypeSuccess
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
437 extern const CFStringRef kSecPropertyTypeSection
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
438 extern const CFStringRef kSecPropertyTypeData
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
439 extern const CFStringRef kSecPropertyTypeString
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
440 extern const CFStringRef kSecPropertyTypeURL
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
441 extern const CFStringRef kSecPropertyTypeDate
__OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
444 @function SecCertificateCopyValues
445 @abstract Creates a dictionary that represents a certificate's contents.
446 @param certificate The certificate from which to get values
447 @param keys An array of string OID values, or NULL. If present, this is
448 the subset of values from the certificate to return. If NULL,
449 all values will be returned. Only OIDs that are top level keys
450 in the returned dictionary can be specified. Unknown OIDs are
452 @param error An optional pointer to a CFErrorRef. This value is
453 set if an error occurred. If not NULL the caller is
454 responsible for releasing the CFErrorRef.
455 @discussion The keys array will contain all of the keys used in the
456 returned dictionary. The top level keys in the returned
457 dictionary are OIDs, many of which are found in SecCertificateOIDs.h.
458 Each entry that is returned is itself a dictionary with four
459 entries, whose keys are kSecPropertyKeyType, kSecPropertyKeyLabel,
460 kSecPropertyKeyLocalizedLabel, kSecPropertyKeyValue. The label
461 entries may contain a descriptive (localized) string, or an
462 OID string. The kSecPropertyKeyType describes the type in the
463 value entry. The value entry may be any CFType, although it
464 is usually a CFStringRef, CFArrayRef or a CFDictionaryRef.
467 CFDictionaryRef
SecCertificateCopyValues(SecCertificateRef certificate
, CFArrayRef __nullable keys
, CFErrorRef
*error
)
468 __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
471 @function SecCertificateCopyLongDescription
472 @abstract Return the long description of a certificate
473 @param alloc The CFAllocator which should be used to allocate
474 memory for the dictionary and its storage for values. This
475 parameter may be NULL in which case the current default
476 CFAllocator is used. If this reference is not a valid
477 CFAllocator, the behavior is undefined.
478 @param certificate The certificate from which to retrieve the long description
479 @param error An optional pointer to a CFErrorRef. This value is
480 set if an error occurred. If not NULL the caller is
481 responsible for releasing the CFErrorRef.
482 @result A CFStringRef of the long description or NULL. If NULL and the error
483 parameter is supplied the error will be returned in the error parameter
484 @discussion Note that the format of this string may change in the future
488 CFStringRef
SecCertificateCopyLongDescription(CFAllocatorRef __nullable alloc
, SecCertificateRef certificate
, CFErrorRef
*error
)
489 __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
492 @function SecCertificateCopyShortDescription
493 @abstract Return the short description of a certificate
494 @param alloc The CFAllocator which should be used to allocate
495 memory for the dictionary and its storage for values. This
496 parameter may be NULL in which case the current default
497 CFAllocator is used. If this reference is not a valid
498 CFAllocator, the behavior is undefined.
499 @param certificate The certificate from which to retrieve the short description
500 @param error An optional pointer to a CFErrorRef. This value is
501 set if an error occurred. If not NULL the caller is
502 responsible for releasing the CFErrorRef.
503 @result A CFStringRef of the short description or NULL. If NULL and the error
504 parameter is supplied the error will be returned in the error parameter
505 @discussion Note that the format of this string may change in the future
509 CFStringRef
SecCertificateCopyShortDescription(CFAllocatorRef __nullable alloc
, SecCertificateRef certificate
, CFErrorRef
*error
)
510 __OSX_AVAILABLE_STARTING(__MAC_10_7
, __IPHONE_NA
);
513 @function SecCertificateCopyNormalizedIssuerContent
514 @abstract Return the certificate's normalized issuer
515 @param certificate The certificate from which to get values
516 @param error An optional pointer to a CFErrorRef. This value is
517 set if an error occurred. If not NULL the caller is
518 responsible for releasing the CFErrorRef.
519 @discussion The issuer is a sequence in the format used by
520 SecItemCopyMatching. The content returned is a DER-encoded
521 X.509 distinguished name. For a display version of the issuer,
522 call SecCertificateCopyValues. The caller must CFRelease
527 CFDataRef
SecCertificateCopyNormalizedIssuerContent(SecCertificateRef certificate
, CFErrorRef
*error
)
528 __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_7
, __MAC_10_12_4
, __IPHONE_NA
, __IPHONE_NA
, "SecCertificateCopyNormalizedIssuerContent is deprecated. Use SecCertificateCopyNormalizedIssuerSequence instead.");
531 @function SecCertificateCopyNormalizedSubjectContent
532 @abstract Return the certificate's normalized subject
533 @param certificate The certificate from which to get values
534 @param error An optional pointer to a CFErrorRef. This value is
535 set if an error occurred. If not NULL the caller is
536 responsible for releasing the CFErrorRef.
537 @discussion The subject is a sequence in the format used by
538 SecItemCopyMatching. The content returned is a DER-encoded
539 X.509 distinguished name. For a display version of the subject,
540 call SecCertificateCopyValues. The caller must CFRelease
545 CFDataRef
SecCertificateCopyNormalizedSubjectContent(SecCertificateRef certificate
, CFErrorRef
*error
)
546 __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_7
, __MAC_10_12_4
, __IPHONE_NA
, __IPHONE_NA
, "SecCertificateCopyNormalizedSubjectContent is deprecated. Use SecCertificateCopyNormalizedSubjectSequence instead.");
549 #endif /* SEC_OS_OSX */
551 CF_IMPLICIT_BRIDGING_DISABLED
552 CF_ASSUME_NONNULL_END
556 #endif /* !_SECURITY_SECCERTIFICATE_H_ */