---
name: "radcli_ctx_set_secret"
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_secret"
---

# radcli\_ctx\_set\_secret(3)

Set the RADIUS shared secret for the configured authserver and/or acctserver.

## NAME

radcli\_ctx\_set\_secret - Set the RADIUS shared secret for the configured authserver and/or acctserver.

## SYNOPSIS

```
#include <radcli/>

int radcli_ctx_set_secret(
    radcli_ctx  *ctx,
    unsigned     target_mask,
    const char  *secret
);
```

## DESCRIPTION

The equivalent, for the new API, of embedding a secret in the host:port:secret form of #RADCLI\_OPT\_AUTHSERVER/#RADCLI\_OPT\_ACCTSERVER's value  but as a distinct call instead of a delimited string, and able to set both server types' secret at once when they share one (the usual case) via RADCLI\_SECRET\_AUTH \| RADCLI\_SECRET\_ACCT, without embedding anything in the authserver/acctserver value at all.

## PARAMETERS

- **ctx**

  a context whose #RADCLI\_OPT\_AUTHSERVER and/or #RADCLI\_OPT\_ACCTSERVER (per target\_mask) is already set  via radcli\_ctx\_set\_opt\_str() or radcli\_ctx\_read\_config()  before this call.

- **target\_mask**

  a bitwise OR of one or both radcli\_secret\_target values.

- **secret**

  the shared secret, as a NUL-terminated string.

## RETURN VALUE

0 on success, -1 on failure (NULL ctx/secret, target\_mask empty or carrying an unrecognised bit, or the corresponding server not yet configured).

## 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\_tls\_psk*(3)](/radcli_ctx_set_tls_psk/3.md)
