## InfCertificateChain InfCertificateChain — X.509 certificate chains |

## Stability Level

Unstable, unless otherwise indicated

## Synopsis

    #include <libinfinity/common/inf-certificate-chain.h>

                        InfCertificateChain;
    InfCertificateChain * inf_certificate_chain_new         (gnutls_x509_crt_t *certs,
                                                             guint n_certs);
    InfCertificateChain * inf_certificate_chain_ref         (InfCertificateChain *chain);
    void                inf_certificate_chain_unref         (InfCertificateChain *chain);
    gnutls_x509_crt_t * inf_certificate_chain_get_raw       (const InfCertificateChain *chain);
    gnutls_x509_crt_t   inf_certificate_chain_get_root_certificate
                                                            (const InfCertificateChain *chain);
    gnutls_x509_crt_t   inf_certificate_chain_get_own_certificate
                                                            (const InfCertificateChain *chain);
    gnutls_x509_crt_t   inf_certificate_chain_get_nth_certificate
                                                            (const InfCertificateChain *chain,
                                                             guint n);
    guint               inf_certificate_chain_get_n_certificates
                                                            (const InfCertificateChain *chain);

## Object Hierarchy

      GBoxed
       +----InfCertificateChain

## Description

InfCertificateChain is a reference-counted wrapper around an array of gnutls_x509_crt_t structures, representing a certificate chain.

## Details

### InfCertificateChain

    typedef struct _InfCertificateChain InfCertificateChain;

InfCertificateChain is an opaque data type. You should only access it via the public API functions.

### inf_certificate_chain_new ()

    InfCertificateChain * inf_certificate_chain_new         (gnutls_x509_crt_t *certs,
                                                             guint n_certs);

Creates a new InfCertificateChain with the given certificates. The `certs` array needs to be allocated with g_malloc. This function takes ownership of `certs`.

`certs` : | Array of certificates.
`n_certs` : | Number of elements in `certs`.
Returns : | A new InfCertificateChain.

### inf_certificate_chain_ref ()

    InfCertificateChain * inf_certificate_chain_ref         (InfCertificateChain *chain);

Increases the reference count of `chain` by one.

`chain` : | A InfCertificateChain:
Returns : | The same `chain`.

### inf_certificate_chain_unref ()

    void                inf_certificate_chain_unref         (InfCertificateChain *chain);

Decreases the reference count of `chain` by one. If the reference count reaches zero, then `chain` is freed.

`chain` : | A InfCertificateChain.

### inf_certificate_chain_get_raw ()

    gnutls_x509_crt_t * inf_certificate_chain_get_raw       (const InfCertificateChain *chain);

Returns the raw array of certificates in the chain.

`chain` : | A InfCertificateChain.
Returns : | An array of certificates owned by the chain.

### inf_certificate_chain_get_root_certificate ()

    gnutls_x509_crt_t   inf_certificate_chain_get_root_certificate
                                                            (const InfCertificateChain *chain);

Returns the last certificate in the chain.

`chain` : | A InfCertificateChain.
Returns : | The last certificate in the chain.

### inf_certificate_chain_get_own_certificate ()

    gnutls_x509_crt_t   inf_certificate_chain_get_own_certificate
                                                            (const InfCertificateChain *chain);

TODO: Rename this function into something more appropriate.

Returns the first certificate in the chain.

`chain` : | A InfCertificateChain.
Returns : | The first certificate in the chain.

### inf_certificate_chain_get_nth_certificate ()

    gnutls_x509_crt_t   inf_certificate_chain_get_nth_certificate
                                                            (const InfCertificateChain *chain,
                                                             guint n);

Returns the `n`th certificate in the chain.

`chain` : | A InfCertificateChain.
`n` : | Index of the certificate to retrieve.
Returns : | The nth certificate in the chain.

### inf_certificate_chain_get_n_certificates ()

    guint               inf_certificate_chain_get_n_certificates
                                                            (const InfCertificateChain *chain);

## See Also

InfXmppConnection