Greenbone Vulnerability Management Libraries 22.41.0
Macros | Functions
tlsutils.c File Reference

TLS certificate utilities. More...

#include "tlsutils.h"
#include <string.h>

Macros

#define G_LOG_DOMAIN   "libgvm util"
 GLib logging domain.
 

Functions

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.
 
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.
 
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.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "libgvm util"

GLib logging domain.

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]encodedThe Base64 data as a NUL-terminated string
[in,out]decoded_datumThe 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]pkcs12PKCS12 data to get data from
[in]passphrasePassphrase to decrypt PKCS12 data
[out]privkey_outOptional private key output
[out]cert_chain_outOptional certificate chain output
[out]extra_certs_outOptional extra certificates output
[out]crl_outOptional 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]certsThe cerificate list to free.
[in]certs_countThe 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]certsThe array of certificates to export
[in]certs_countThe 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]crlThe 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_dataThe certificate data.
[in]cert_lenLength 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]privkeyThe private key to export.
Returns
The private key as a PEM string, or NULL on error.