### Constructor

# Gio TlsCertificate new_from_files

since: 2.28

#### Declaration

    GTlsCertificate*
    g_tls_certificate_new_from_files (
      const gchar* cert_file,
      const gchar* key_file,
      GError** error
    )

#### Description

Creates a `GTlsCertificate` from the PEM-encoded data in `cert_file` and `key_file`. The returned certificate will be the first certificate found in `cert_file`. As of GLib 2.44, if `cert_file` contains more certificates it will try to load a certificate chain. All certificates will be verified in the order found (top-level certificate should be the last one in the file) and the `GTlsCertificate:issuer` property of each certificate will be set accordingly if the verification succeeds. If any certificate in the chain cannot be verified, the first certificate in the file will still be returned.

If either file cannot be read or parsed, the function will return `NULL` and set `error`. Otherwise, this behaves like g_tls_certificate_new_from_pem().

Available since: 2.28

#### Parameters

`cert_file`

  Type: `const gchar*`

  File containing one or more PEM-encoded certificates to import.

  The data is owned by the caller of the function.
  The value is a file system path, using the OS encoding.

`key_file`

  Type: `const gchar*`

  File containing a PEM-encoded private key to import.

  The data is owned by the caller of the function.
  The value is a file system path, using the OS encoding.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the constructor if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `GTlsCertificate`

The new certificate, or `NULL` on error.

The caller of the function takes ownership of the data, and is responsible for freeing it.