---
name: "radcli_ctx_set_tls_psk"
section: "3"
platform: "linux"
package: "radcli"
version: "2.0.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/radcli_ctx_set_tls_psk"
---

# radcli\_ctx\_set\_tls\_psk(3)

Set the RFC 6614/7360 TLS-transport Pre-Shared Key credentials for the configured authserver.

## NAME

radcli\_ctx\_set\_tls\_psk - Set the RFC 6614/7360 TLS-transport Pre-Shared Key credentials for the configured authserver.

## SYNOPSIS

```
#include <radcli/>

int radcli_ctx_set_tls_psk(
    radcli_ctx     *ctx,
    const void     *identity,
    size_t          identity_len,
    const uint8_t  *key,
    size_t          keylen
);
```

## DESCRIPTION

The equivalent, for the new API, of the legacy authserver host:port:psk@username@hexkey inline form  but with identity and key as independent byte buffers instead of a delimited string, so a username containing @ cannot be misparsed (the legacy form splits on the first @ after the psk@ prefix) and the key never needs to be hex-encoded by the caller. Only meaningful when #RADCLI\_OPT\_SERV\_TYPE is tls or dtls; takes priority over any psk@username@hexkey embedded in #RADCLI\_OPT\_AUTHSERVER's value, should both somehow be set.

## PARAMETERS

- **ctx**

  a context, before radcli\_ctx\_apply().

- **identity**

  the PSK identity; GnuTLS treats this as a NUL-terminated string once passed on, so an identity containing an embedded NUL byte is truncated there  a GnuTLS API constraint, not an ambiguity this function introduces.

- **identity\_len**

  identity's length in bytes.

- **key**

  the raw PSK key bytes (not hex-encoded text).

- **keylen**

  key's length in bytes.

## RETURN VALUE

0 on success, -1 on failure (NULL ctx/identity/key, or keylen 0).

## SEE ALSO

[*radcli\_ctx\_apply*(3)](/radcli_ctx_apply/3.md), [*radcli\_ctx\_free*(3)](/radcli_ctx_free/3.md), [*radcli\_ctx\_get\_opt\_int*(3)](/radcli_ctx_get_opt_int/3.md), [*radcli\_ctx\_get\_opt\_str*(3)](/radcli_ctx_get_opt_str/3.md), [*radcli\_ctx\_new*(3)](/radcli_ctx_new/3.md), [*radcli\_ctx\_read\_config*(3)](/radcli_ctx_read_config/3.md), [*radcli\_ctx\_read\_dictionary*(3)](/radcli_ctx_read_dictionary/3.md), [*radcli\_ctx\_read\_dictionary\_from\_buffer*(3)](/radcli_ctx_read_dictionary_from_buffer/3.md), [*radcli\_ctx\_set\_opt\_int*(3)](/radcli_ctx_set_opt_int/3.md), [*radcli\_ctx\_set\_opt\_str*(3)](/radcli_ctx_set_opt_str/3.md), [*radcli\_ctx\_set\_secret*(3)](/radcli_ctx_set_secret/3.md)
