gnutls_certificate_type_get - Linux


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.


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


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


  • To check if a certificate is a client certificate:
gnutls_datum_t out;
gnutls_certificate_type_get(&out, cert);
if ( == GNUTLS_CRT_X509) {
    // Certificate is X.509
} else if ( == 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.


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