Discussion about TLS certificates is usually about how clients authenticate servers. However, both TLS and k6 also support the reverse process, in which servers authenticate clients.
To use client certificates, specify global configuration options that tell k6 how to map a public certificate and private key to the domains they are valid for. You can load the certificate and key from local files or embed them as strings in the script.
Loading a certificate and a key from local files
To load a certificate and a key from local files, use the builtin open(...) function:
TLS client certificates from local certificate and key files
Loading certificate and key from embedded strings
To load the certificate and key from embedded strings, use this snippet. Note the use of template literals for multi-line strings):
⚠ These are just example keys
They're not real and were never used anywhere.
TLS client certificates from local certificate and key files