## InfCertificateChain

InfCertificateChain — X.509 certificate chains

## Stability Level

Unstable, unless otherwise indicated

## Functions

InfCertificateChain * | inf_certificate_chain_new ()
InfCertificateChain * | inf_certificate_chain_ref ()
void | inf_certificate_chain_unref ()
gnutls_x509_crt_t * | inf_certificate_chain_get_raw ()
gnutls_x509_crt_t | inf_certificate_chain_get_root_certificate ()
gnutls_x509_crt_t | inf_certificate_chain_get_own_certificate ()
gnutls_x509_crt_t | inf_certificate_chain_get_nth_certificate ()
guint | inf_certificate_chain_get_n_certificates ()

## Types and Values

| InfCertificateChain

## Object Hierarchy

        GBoxed
        ╰── InfCertificateChain

## Includes

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

## Description

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

## 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` .

#### Parameters

certs | Array of certificates. | [array length=n_certs]
n_certs | Number of elements in `certs` . |

#### Returns

A new InfCertificateChain.

[transfer full]

### inf_certificate_chain_ref ()

    InfCertificateChain *
    inf_certificate_chain_ref (InfCertificateChain *chain);

Increases the reference count of `chain` by one.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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);

Returns the number of certificates in `chain` .

#### Parameters

chain | A InfCertificateChain. |

#### Returns

The number of certificates in `chain` .

## Types and Values

### InfCertificateChain

    typedef struct _InfCertificateChain InfCertificateChain;

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

## See Also

InfXmppConnection