"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "util/serverutils.c" between
gvm-libs-11.0.0.tar.gz and gvm-libs-11.0.1.tar.gz

About: GVM Libraries for the Greenbone Vulnerability Management (GVM-10) framework (derived from the former openvas-libraries).

serverutils.c  (gvm-libs-11.0.0):serverutils.c  (gvm-libs-11.0.1)
skipping to change at line 219 skipping to change at line 219
{ {
if (data) if (data)
g_free (data->data); g_free (data->data);
} }
static char *cert_pub_mem = NULL; static char *cert_pub_mem = NULL;
static char *cert_priv_mem = NULL; static char *cert_priv_mem = NULL;
/** /**
* @brief Save cert_pub_mem with public certificate. * @brief Save cert_pub_mem with public certificate.
*
* @param[in] data The DER or PEM encoded certificate. * @param[in] data The DER or PEM encoded certificate.
*/ */
static void static void
set_cert_pub_mem (const char *data) set_cert_pub_mem (const char *data)
{ {
if (cert_pub_mem) if (cert_pub_mem)
g_free (cert_pub_mem); g_free (cert_pub_mem);
cert_pub_mem = g_strdup (data); cert_pub_mem = g_strdup (data);
} }
/** /**
* @brief Save cert_priv_mem with private certificate. * @brief Save cert_priv_mem with private certificate.
*
* @param[in] data The DER or PEM encoded certificate. * @param[in] data The DER or PEM encoded certificate.
*/ */
static void static void
set_cert_priv_mem (const char *data) set_cert_priv_mem (const char *data)
{ {
if (cert_priv_mem) if (cert_priv_mem)
g_free (cert_priv_mem); g_free (cert_priv_mem);
cert_priv_mem = g_strdup (data); cert_priv_mem = g_strdup (data);
} }
/** /**
* @brief Get private certificate from @ref cert_priv_mem. * @brief Get private certificate from @ref cert_priv_mem.
*
* @return The DER or PEM encoded certificate. * @return The DER or PEM encoded certificate.
*/ */
static const char * static const char *
get_cert_priv_mem () get_cert_priv_mem ()
{ {
return cert_priv_mem; return cert_priv_mem;
} }
/** /**
* @brief Get public certificate from @ref cert_pub_mem. * @brief Get public certificate from @ref cert_pub_mem.
*
* @return The DER or PEM encoded certificate. * @return The DER or PEM encoded certificate.
*/ */
static const char * static const char *
get_cert_pub_mem () get_cert_pub_mem ()
{ {
return cert_pub_mem; return cert_pub_mem;
} }
/** /**
* @brief Callback function to be called in order to retrieve the * @brief Callback function to be called in order to retrieve the
certificate to be used in the handshake. * certificate to be used in the handshake.
*
* @param[in] session Pointer to GNUTLS session. Not in used. Can be NULL. * @param[in] session Pointer to GNUTLS session. Not in used. Can be NULL.
* @param[in] req_ca_rdn Contains a list with the CA names that * @param[in] req_ca_rdn Contains a list with the CA names that
* the server considers trusted. Not in used. Can be NULL. * the server considers trusted. Not in used. Can be NULL.
* @param[in] nreqs Number of CA requested. Not in used. Can be NULL. * @param[in] nreqs Number of CA requested. Not in used. Can be NULL.
* @param[in] sign_algos contains a list with server's acceptable public key * @param[in] sign_algos contains a list with server's acceptable public key
* algorithms. Not in used. Can be NULL. * algorithms. Not in used. Can be NULL.
* @param[in] sign_algos_length Algos list length. Not in used. Can be NULL. * @param[in] sign_algos_length Algos list length. Not in used. Can be NULL.
* @param[out] st Should contain the certificates and private keys * @param[out] st Should contain the certificates and private keys
*
* @return 0 on success, non-null otherwise. * @return 0 on success, non-null otherwise.
*/ */
static int static int
client_cert_callback (gnutls_session_t session, client_cert_callback (gnutls_session_t session,
const gnutls_datum_t *req_ca_rdn, int nreqs, const gnutls_datum_t *req_ca_rdn, int nreqs,
const gnutls_pk_algorithm_t *sign_algos, const gnutls_pk_algorithm_t *sign_algos,
int sign_algos_length, gnutls_retr2_st *st) int sign_algos_length, gnutls_retr2_st *st)
{ {
int ret; int ret;
gnutls_datum_t data; gnutls_datum_t data;
skipping to change at line 998 skipping to change at line 1004
va_start (ap, format); va_start (ap, format);
msg = g_markup_vprintf_escaped (format, ap); msg = g_markup_vprintf_escaped (format, ap);
rc = gvm_connection_sendf_quiet (connection, "%s", msg); rc = gvm_connection_sendf_quiet (connection, "%s", msg);
g_free (msg); g_free (msg);
va_end (ap); va_end (ap);
return rc; return rc;
} }
/** /**
* @brief Initialize a server session. * @brief Initialize a server session.
*
* @param[in] server_credentials Credentials to be allocated. * @param[in] server_credentials Credentials to be allocated.
*
* @return 0 on success, -1 on error. * @return 0 on success, -1 on error.
*/ */
static int static int
server_new_gnutls_init (gnutls_certificate_credentials_t *server_credentials) server_new_gnutls_init (gnutls_certificate_credentials_t *server_credentials)
{ {
/* Turn off use of /dev/random, as this can block. */ /* Turn off use of /dev/random, as this can block. */
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
/* Initialize security library. */ /* Initialize security library. */
if (gnutls_global_init ()) if (gnutls_global_init ())
skipping to change at line 1024 skipping to change at line 1032
if (gnutls_certificate_allocate_credentials (server_credentials)) if (gnutls_certificate_allocate_credentials (server_credentials))
{ {
g_warning ("%s: failed to allocate server credentials\n", __FUNCTION__); g_warning ("%s: failed to allocate server credentials\n", __FUNCTION__);
return -1; return -1;
} }
return 0; return 0;
} }
/** /**
* @brief Set the server credencials. * @brief Set the server credencials.
*
* @param[in] end_type Connection end type. * @param[in] end_type Connection end type.
* @param[in] priority TLS priority to be set. If no one is given, NORMAL is * @param[in] priority TLS priority to be set. If no one is given, NORMAL is
* default. * default.
* @param[in] server_session GNUTLS session. * @param[in] server_session GNUTLS session.
* @param[in] server_credentials Credentials to be set. * @param[in] server_credentials Credentials to be set.
*
* @return 0 on success, -1 on error. * @return 0 on success, -1 on error.
*/ */
static int static int
server_new_gnutls_set (unsigned int end_type, const char *priority, server_new_gnutls_set (unsigned int end_type, const char *priority,
gnutls_session_t *server_session, gnutls_session_t *server_session,
gnutls_certificate_credentials_t *server_credentials) gnutls_certificate_credentials_t *server_credentials)
{ {
int err_gnutls; int err_gnutls;
if (gnutls_init (server_session, end_type)) if (gnutls_init (server_session, end_type))
 End of changes. 10 change blocks. 
1 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)