Gcr.Certificate
Description: Reference for Gcr.Certificate

### Interface

# GcrCertificate

since: 3

#### Description [src]

    interface Gcr.Certificate : Gcr.Comparable

An interface that represents an X.509 certificate.

Objects can implement this interface to make a certificate usable with the GCR library.

Various methods are available to parse out relevant bits of the certificate. However no verification of the validity of a certificate is done here. Use your favorite crypto library to do this.

You can use `GcrSimpleCertificate` to simply load a certificate for which you already have the raw certificate data.

The `GcrCertificate` interface has several properties that must be implemented. You can use a mixin to implement these properties if desired. See the `gcr_certificate_mixin_class_init()` and `gcr_certificate_mixin_get_property()` functions.

All certificates are comparable. If implementing a `GcrCertificate`, you can use GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE() to implement the `GcrComparable` interface.

Available since: 3

#### Prerequisite

In order to implement Certificate, your type must inherit from`GcrComparable`.

#### Implementations

- GcrPkcs11Certificate
- GcrSimpleCertificate

#### Functions

###### gcr_certificate_compare

Compare one certificate against another. If the certificates are equal then zero is returned. If one certificate is `NULL` or not a certificate, then a non-zero value is returned.

since: 3

###### gcr_certificate_get_columns

Get the columns appropriate for a certificate.

since: 3

###### gcr_certificate_mixin_class_init

Initialize the certificate mixin for the class. This mixin implements the various required properties for the certificate.

since: 3

###### gcr_certificate_mixin_comparable_init

Initialize a `GcrComparableIface` to compare the current certificate. In general it’s easier to use the GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE() macro instead of this function.

since: 3

###### gcr_certificate_mixin_get_property

Implementation to get various required certificate properties. This should be called from your derived class get_property function, or used as a get_property virtual function.

since: 3

#### Instance methods

###### gcr_certificate_get_basic_constraints

Get the basic constraints for the certificate if present. If `FALSE` is returned then no basic constraints are present and the `is_ca` and `path_len` arguments are not changed.

since: 3

###### gcr_certificate_get_der_data

Gets the raw DER data for an X.509 certificate.

since: 3

###### gcr_certificate_get_expiry_date

Get the expiry date of this certificate.

since: 3

###### gcr_certificate_get_fingerprint

Calculate the fingerprint for this certificate.

since: 3

###### gcr_certificate_get_fingerprint_hex

Calculate the fingerprint for this certificate, and return it as a hex string.

since: 3

###### gcr_certificate_get_icon

Get the icon for a certificate.

since: 3

###### gcr_certificate_get_issued_date

Get the issued date of this certificate.

since: 3

###### gcr_certificate_get_issuer_cn

Get the common name of the issuer of this certificate.

since: 3

###### gcr_certificate_get_issuer_dn

Get the full issuer DN of the certificate as a (mostly) readable string.

since: 3

###### gcr_certificate_get_issuer_name

Get a name to represent the issuer of this certificate.

since: 3

###### gcr_certificate_get_issuer_part

Get a part of the DN of the issuer of this certificate.

since: 3

###### gcr_certificate_get_issuer_raw

Get the raw DER data for the issuer DN of the certificate.

since: 3

###### gcr_certificate_get_key_size

Get the key size in bits of the public key represented by this certificate.

since: 3

###### gcr_certificate_get_markup_text

Calculate a GMarkup string for displaying this certificate.

since: 3

###### gcr_certificate_get_serial_number

Get the raw binary serial number of the certificate.

since: 3

###### gcr_certificate_get_serial_number_hex

Get the serial number of the certificate as a hex string.

since: 3

###### gcr_certificate_get_subject_cn

Get the common name of the subject of this certificate.

since: 3

###### gcr_certificate_get_subject_dn

Get the full subject DN of the certificate as a (mostly) readable string.

since: 3

###### gcr_certificate_get_subject_name

Get a name to represent the subject of this certificate.

since: 3

###### gcr_certificate_get_subject_part

Get a part of the DN of the subject of this certificate.

since: 3

###### gcr_certificate_get_subject_raw

Get the raw DER data for the subject DN of the certificate.

since: 3

###### gcr_certificate_is_issuer

Check if `issuer` could be the issuer of this certificate. This is done by comparing the relevant subject and issuer fields. No signature check is done. Proper verification of certificates must be done via a crypto library.

since: 3

###### gcr_certificate_mixin_emit_notify

Implementers of the `GcrCertificate` mixin should call this function to notify when the certificate has changed to emit notifications on the various properties.

since: 3

#### Properties

###### Gcr.Certificate:description

A readable description for this certificate.

since: 3

###### Gcr.Certificate:expiry

The expiry date of the certificate.

since: 3

###### Gcr.Certificate:icon

An icon representing the certificate.

since: 3

###### Gcr.Certificate:issuer

Common name part of the certificate issuer.

since: 3

###### Gcr.Certificate:label

A readable label for this certificate.

since: 3

###### Gcr.Certificate:markup

GLib markup to describe the certificate.

since: 3

###### Gcr.Certificate:subject

Common name part of the certificate subject.

since: 3

#### Interface structure

    struct GcrCertificateIface {
      GTypeInterface parent;
      const guint8* (* get_der_data) (
        GcrCertificate* self,
        gsize* n_data
      );

    }

The interface that implementors of `GcrCertificate` must implement.

###### Interface members

`parent` |
    GTypeInterface
| The parent interface type.
`get_der_data` |
    const guint8* (* get_der_data) (
        GcrCertificate* self,
        gsize* n_data
      )
| No description available.

#### Virtual methods

###### Gcr.Certificate.get_der_data

Gets the raw DER data for an X.509 certificate.

since: 3