Greenbone Vulnerability Management Libraries: util/tlsutils.h File Reference

Greenbone Vulnerability Management Libraries 23.1.2

Functions
tlsutils.h File Reference

TLS certificate utilities headers. More...

`#include <glib.h>`
`#include <gnutls/gnutls.h>`
`#include <gnutls/pkcs12.h>`

Go to the source code of this file.

## Functions
gnutls_x509_crt_fmt_t | gvm_x509_format_from_data (const char *, size_t)
| Try to determine the format (DER or PEM) of a x509 certificate.
int | gvm_base64_to_gnutls_datum (const char *, gnutls_datum_t *)
| Decode a Base64 string to the contents of a gnutls_datum_t.
void | gvm_x509_cert_list_free (gnutls_x509_crt_t *certs, unsigned int certs_count)
| Frees a list of X509 certificates.
gchar * | gvm_x509_privkey_to_pem (gnutls_x509_privkey_t privkey)
| Export a GnuTLS x509 private key as a PEM formatted string.
gchar * | gvm_x509_cert_list_to_pem (gnutls_x509_crt_t *certs, unsigned int certs_count)
| Export a GnuTLS x509 cerificate list as a PEM formatted string.
gchar * | gvm_x509_crl_to_pem (gnutls_x509_crl_t crl)
| Export a GnuTLS x509 CRL as a PEM formatted string.
int | gvm_pkcs12_to_pem (gnutls_pkcs12_t pkcs12, const char *passphrase, gchar **privkey_out, gchar **cert_chain_out, gchar **extra_certs_out, gchar **crl_out)
| Convert GnuTLS PKCS12 data to a PEM formatted string.

## Detailed Description

TLS certificate utilities headers.

## Function Documentation

## ◆ gvm_base64_to_gnutls_datum()

int gvm_base64_to_gnutls_datum | ( | const char * | encoded,
|  | gnutls_datum_t * | decoded_datum )

Decode a Base64 string to the contents of a gnutls_datum_t.

Parameters

  [in] | encoded | The Base64 data as a NUL-terminated string
  [in,out] | decoded_datum | The datum struct to decode to.

Returns
  The return code from gnutls_base64_decode2

## ◆ gvm_pkcs12_to_pem()

int gvm_pkcs12_to_pem | ( | gnutls_pkcs12_t | pkcs12,
|  | const char * | passphrase,
|  | gchar ** | privkey_out,
|  | gchar ** | cert_chain_out,
|  | gchar ** | extra_certs_out,
|  | gchar ** | crl_out )

Convert GnuTLS PKCS12 data to a PEM formatted string.

Parameters

  [in] | pkcs12 | PKCS12 data to get data from
  [in] | passphrase | Passphrase to decrypt PKCS12 data
  [out] | privkey_out | Optional private key output
  [out] | cert_chain_out | Optional certificate chain output
  [out] | extra_certs_out | Optional extra certificates output
  [out] | crl_out | Optional CRL output

Returns
  0 success or a GnuTLS error code if decryption or parsing fails.

## ◆ gvm_x509_cert_list_free()

void gvm_x509_cert_list_free | ( | gnutls_x509_crt_t * | certs,
|  | unsigned int | certs_count )

Frees a list of X509 certificates.

Parameters

  [in] | certs | The cerificate list to free.
  [in] | certs_count | The number of certificates in the list.

## ◆ gvm_x509_cert_list_to_pem()

gchar * gvm_x509_cert_list_to_pem | ( | gnutls_x509_crt_t * | certs,
|  | unsigned int | certs_count )

Export a GnuTLS x509 cerificate list as a PEM formatted string.

Parameters

  [in] | certs | The array of certificates to export
  [in] | certs_count | The number of certificates to export

Returns
  The certificates as a PEM string, or NULL on error.

## ◆ gvm_x509_crl_to_pem()

gchar * gvm_x509_crl_to_pem | ( | gnutls_x509_crl_t | crl | ) |

Export a GnuTLS x509 CRL as a PEM formatted string.

Parameters

  [in] | crl | The certificate revocation list CRL

Returns
  The certificates as a PEM string, or NULL on error.

## ◆ gvm_x509_format_from_data()

gnutls_x509_crt_fmt_t gvm_x509_format_from_data | ( | const char * | cert_data,
|  | size_t | cert_len )

Try to determine the format (DER or PEM) of a x509 certificate.

Parameters

  [in] | cert_data | The certificate data.
  [in] | cert_len | Length of the certificate data.

Returns
  The GnuTLS x509 certificate type.

## ◆ gvm_x509_privkey_to_pem()

gchar * gvm_x509_privkey_to_pem | ( | gnutls_x509_privkey_t | privkey | ) |

Export a GnuTLS x509 private key as a PEM formatted string.

Parameters

  [in] | privkey | The private key to export.

Returns
  The private key as a PEM string, or NULL on error.