gnutls_certificate_type_get - Linux


Overview

gnutls_certificate_type_get() retrieves the certificate type of an X.509 certificate using GnuTLS. It checks whether the given certificate is of a particular type.

Syntax

int gnutls_certificate_type_get(gnutls_datum_t *out,
                               const gnutls_certificate_t cert);

Options/Flags

  • out: A pointer to a gnutls_datum_t which will receive the certificate type.
  • cert: A pointer to the gnutls_certificate_t to check.

Examples

  • To check if a certificate is a client certificate:
gnutls_datum_t out;
gnutls_certificate_type_get(&out, cert);
if (out.data == GNUTLS_CRT_X509) {
    // Certificate is X.509
} else if (out.data == GNUTLS_CRT_OPENPGP) {
    // Certificate is OpenPGP
}

Common Issues

  • Make sure that the certificate argument is valid.
  • The certificate type is returned in the out argument.

Integration

gnutls_certificate_type_get() can be used with other GnuTLS functions to verify certificates and establish secure connections.

Related Commands

  • gnutls_certificate_verify()
  • gnutls_certificate_list_init()