gnutls_certificate_set_x509_key_file - Linux


The gnutls_certificate_set_x509_key_file function in GnuTLS sets the private key to be associated with the certificate. The private key must be in PEM format.


int gnutls_certificate_set_x509_key_file(gnutls_certificate_credentials_t cred, const char *filename);


| Option | Description |
| cred | The credentials to add the certificate and key to. |
| filename | The name of the file containing the private key in PEM format. |


// Set the private key for a certificate
gnutls_certificate_set_x509_key_file(cred, "mykey.pem");

Common Issues

If the private key is not in PEM format, the function will return an error.


This function can be used in conjunction with other GnuTLS functions to create and manage TLS connections.

Related Commands

  • gnutls_certificate_create_credentials
  • gnutls_certificate_set_x509_trust_file
  • gnutls_certificate_set_x509_crl_file