Skip to contents

Generates a node key pair and a random pre-shared key locally, without network access. Pass the result as the key of a TailcatServer to give a server a stable identity and address across restarts, or pass it as the key of a TailcatClient to give a client a stable public key (useful with allowed_clients).

Usage

tailcat_keygen(path = NULL)

Arguments

path

NULL (the default) to return new keys without saving them, or the path of a keys file: if it exists, the keys are loaded from it with tailcat_keys_load(); otherwise new keys are generated and saved there with tailcat_keys_save(). This gives a script the same keys every time it runs.

Value

A list of class tailcat_keys with elements private_key, public_key, and preshared_key, each a string in tailcat's text encoding; private_key and preshared_key are tailcat_secret strings.

Details

The private key and the pre-shared key are secrets. They are tailcat_secret strings, so print(), format(), and str() of the keys, or of the elements, show only the public key and <redacted>. The elements still hold the full values (as.character() or unclass() returns them, and dput() shows them), so store them securely: tailcat_keys_save() writes them to a file only you can read.

Examples

keys = tailcat_keygen()
keys
#> <tailcat_keys>
#>   public_key:    nodekey:8aead8c654cbc7a51dad2cfad232e622041e9c0f897182e9f1b69d8f0d1bd468
#>   private_key:   <redacted>
#>   preshared_key: <redacted>
keys$public_key
#> [1] "nodekey:8aead8c654cbc7a51dad2cfad232e622041e9c0f897182e9f1b69d8f0d1bd468"