Gio.TlsConnection.set_certificate

### Method

# Gio TlsConnectionset_certificate

since: 2.28

#### Declaration [src]

    void
    g_tls_connection_set_certificate (
      GTlsConnection* conn,
      GTlsCertificate* certificate
    )

#### Description [src]

This sets the certificate that `conn` will present to its peer during the TLS handshake. For a `GTlsServerConnection`, it is mandatory to set this, and that will normally be done at construct time.

For a `GTlsClientConnection`, this is optional. If a handshake fails with `G_TLS_ERROR_CERTIFICATE_REQUIRED`, that means that the server requires a certificate, and if you try connecting again, you should call this method first. You can call `g_tls_client_connection_get_accepted_cas()` on the failed connection to get a list of Certificate Authorities that the server will accept certificates from.

(It is also possible that a server will allow the connection with or without a certificate; in that case, if you don’t provide a certificate, you can tell that the server requested one by the fact that `g_tls_client_connection_get_accepted_cas()` will return non-`NULL`.).

Available since: 2.28

Sets property | `Gio.TlsConnection:certificate`

#### Parameters

`certificate`

  Type: `GTlsCertificate`

  The certificate to use for `conn`.

  The data is owned by the caller of the method.