### Method

# Gcr CertificateChain build

#### Declaration [src]

    gboolean
    gcr_certificate_chain_build (
      GcrCertificateChain* self,
      const gchar* purpose,
      const gchar* peer,
      GcrCertificateChainFlags flags,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

Complete a certificate chain. Once a certificate chain has been built its status can be examined.

This operation will lookup missing certificates in PKCS#11 modules and also that each certificate in the chain is the signer of the previous one. If a trust anchor, pinned certificate, or self-signed certificate is found, then the chain is considered built. Any extra certificates are removed from the chain.

It’s important to understand that building of a certificate chain does not constitute verifying that chain. This is merely the first step towards trust verification.

The `purpose` is a string like `GCR_PURPOSE_CLIENT_AUTH` and is the purpose for which the certificate chain will be used. Trust anchors are looked up for this purpose. This argument is required.

The `peer` is usually the host name of the peer whith which this certificate chain is being used. It is used to look up pinned certificates that have been stored for this peer. If `NULL` then no pinned certificates will be considered.

If the `GCR_CERTIFICATE_CHAIN_NO_LOOKUPS` flag is specified then no lookups for anchors or pinned certificates are done, and the resulting chain will be neither anchored or pinned. Additionally no missing certificate authorities are looked up in PKCS#11

This call will block, see `gcr_certificate_chain_build_async()` for the asynchronous version.

#### Parameters

`purpose`

  Type: `const gchar*`

  The purpose the certificate chain will be used for.

  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`peer`

  Type: `const gchar*`

  The peer the certificate chain will be used with, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`flags`

  Type: `GcrCertificateChainFlags`

  Chain completion flags.

`cancellable`

  Type: `GCancellable`

  A `GCancellable` or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`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 method 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: `gboolean`

Whether the operation completed successfully.