---
title: "gss_acquire_cred(_:_:_:_:_:_:_:_:)"
framework: GSS
role: symbol
role_heading: Function
platforms: [iOS 5.0+, iPadOS 5.0+, Mac Catalyst 13.1+, macOS 10.7+, visionOS 1.0+]
path: "gss/gss_acquire_cred(_:_:_:_:_:_:_:_:)"
---

# gss_acquire_cred(_:_:_:_:_:_:_:_:)

Acquires a credential for use in establishing a security context.

## Declaration

```swift
func gss_acquire_cred(_ minor_status: UnsafeMutablePointer<OM_uint32>, _ desired_name: gss_name_t?, _ time_req: OM_uint32, _ desired_mechs: gss_OID_set?, _ cred_usage: gss_cred_usage_t, _ output_cred_handle: UnsafeMutablePointer<gss_cred_id_t?>, _ actual_mechs: UnsafeMutablePointer<gss_OID_set?>?, _ time_rec: UnsafeMutablePointer<OM_uint32>?) -> OM_uint32
```

## Parameters

- `minor_status`: A pointer to the secondary status result that provides additional information in case of failure.
- `desired_name`: The name of the principal whose credential should be acquired. Specify GSS_C_NO_NAME to get a generic credential or use doc://com.apple.gss/documentation/GSS/gss_import_name(_:_:_:_:) to obtain a name object.
- `time_req`: The time in seconds that the credential should remain valid. Use doc://com.apple.gss/documentation/GSS/GSS_C_INDEFINITE to indicate the maximum allowed duration.
- `desired_mechs`: The set of underlying security mechanisms to use with the credential. Use GSS_C_NO_OID_SET to get the default set.
- `cred_usage`: A flag that indicates how the credential will be used. Specify doc://com.apple.gss/documentation/GSS/GSS_C_INITIATE for context initiation, doc://com.apple.gss/documentation/GSS/GSS_C_ACCEPT for context acceptance, or doc://com.apple.gss/documentation/GSS/GSS_C_BOTH for both.
- `output_cred_handle`: A pointer the function uses to return the credential. Release the credential’s memory with doc://com.apple.gss/documentation/GSS/gss_release_cred(_:_:) when you are done with it.
- `actual_mechs`: A pointer the function uses to return the actual mechanisms used by the credential. Set to NULL to ignore this output. If you do receive a set of mechanisms, use doc://com.apple.gss/documentation/GSS/gss_release_oid_set(_:_:) to release its memory when you are done with it.
- `time_rec`: A pointer the function uses to return the actual number of seconds for which the credential is valid. Set to NULL to ignore this output.

## Mentioned in

Allocating and Releasing Objects

## Return Value

Return Value A status code set to GSS_S_COMPLETE on success. See Function Status for a description of other status outputs.

## See Also

### Acquisition

- [gss_aapl_initial_cred(_:_:_:_:_:)](gss/gss_aapl_initial_cred(_:_:_:_:_:).md)
- [gss_acquire_cred_with_password(_:_:_:_:_:_:_:_:_:)](gss/gss_acquire_cred_with_password(_:_:_:_:_:_:_:_:_:).md)
- [GSSCredentialCopyUUID(_:)](gss/gsscredentialcopyuuid(_:).md)
- [GSSCredentialCopyName(_:)](gss/gsscredentialcopyname(_:).md)
- [gss_pseudo_random(_:_:_:_:_:_:)](gss/gss_pseudo_random(_:_:_:_:_:_:).md)
