<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GSS",
  "identifier" : "/documentation/GSS/gss_acquire_cred(_:_:_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "GSS"
    ],
    "preciseIdentifier" : "c:@F@gss_acquire_cred"
  },
  "title" : "gss_acquire_cred(_:_:_:_:_:_:_:_:)"
}
-->

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

Acquires a credential for use in establishing a security context.

```
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 [`gss_import_name(_:_:_:_:)`](/documentation/GSS/gss_import_name(_:_:_:_:)) to obtain a name object.

`time_req`

The time in seconds that the credential should remain valid. Use [`GSS_C_INDEFINITE`](/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 [`GSS_C_INITIATE`](/documentation/GSS/GSS_C_INITIATE) for context initiation, [`GSS_C_ACCEPT`](/documentation/GSS/GSS_C_ACCEPT) for context acceptance, or [`GSS_C_BOTH`](/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 [`gss_release_cred(_:_:)`](/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 [`gss_release_oid_set(_:_:)`](/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.

## Return Value

A status code set to [`GSS_S_COMPLETE`](/documentation/GSS/GSS_S_COMPLETE) on success. See [Function Status](/documentation/GSS/function-status) for a description of other status outputs.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)