|
Greenbone Vulnerability Management Libraries
10.0.0
|
GnuTLS based functions for server communication. More...
#include "serverutils.h"#include "../base/hosts.h"#include <arpa/inet.h>#include <errno.h>#include <fcntl.h>#include <gcrypt.h>#include <glib.h>#include <gnutls/x509.h>#include <netdb.h>#include <signal.h>#include <stdio.h>#include <string.h>#include <sys/socket.h>#include <sys/types.h>#include <unistd.h>
Go to the source code of this file.
Macros | |
| #define | _GNU_SOURCE |
| #define | G_LOG_DOMAIN "lib serv" |
| GLib log domain. More... | |
Functions | |
| static int | server_attach_internal (int socket, gnutls_session_t *session, const char *host, int port) |
| Attach a socket to a session, and shake hands with the peer. More... | |
| static int | server_new_internal (unsigned int end_type, const char *priority, const gchar *ca_cert_file, const gchar *cert_file, const gchar *key_file, gnutls_session_t *server_session, gnutls_certificate_credentials_t *server_credentials) |
| Make a session for connecting to a server. More... | |
| static int | close_unix (gvm_connection_t *client_connection) |
| Close UNIX socket connection. More... | |
| void | gvm_connection_free (gvm_connection_t *client_connection) |
| Free connection. More... | |
| int | gvm_server_verify (gnutls_session_t session) |
| Verify certificate. More... | |
| int | load_gnutls_file (const char *file, gnutls_datum_t *loaded_file) |
| Loads a file's data into gnutls_datum_t struct. More... | |
| void | unload_gnutls_file (gnutls_datum_t *data) |
| Unloads a gnutls_datum_t struct's data. More... | |
| static void | set_cert_pub_mem (const char *data) |
| Save cert_pub_mem with public certificate. More... | |
| static void | set_cert_priv_mem (const char *data) |
| Save cert_priv_mem with private certificate. More... | |
| static const char * | get_cert_priv_mem () |
| Get private certificate from cert_priv_mem. More... | |
| static const char * | get_cert_pub_mem () |
| Get public certificate from cert_pub_mem. More... | |
| static int | client_cert_callback (gnutls_session_t session, const gnutls_datum_t *req_ca_rdn, int nreqs, const gnutls_pk_algorithm_t *sign_algos, int sign_algos_length, gnutls_retr2_st *st) |
| Callback function to be called in order to retrieve the certificate to be used in the handshake. More... | |
| int | gvm_server_open_verify (gnutls_session_t *session, const char *host, int port, const char *ca_mem, const char *pub_mem, const char *priv_mem, int verify) |
| Connect to the server using a given host, port and cert. More... | |
| int | gvm_server_open_with_cert (gnutls_session_t *session, const char *host, int port, const char *ca_mem, const char *pub_mem, const char *priv_mem) |
| Connect to the server using a given host, port and cert. More... | |
| int | gvm_server_open (gnutls_session_t *session, const char *host, int port) |
| Connect to the server using a given host and port. More... | |
| int | gvm_server_close (int socket, gnutls_session_t session) |
| Close a server connection and its socket. More... | |
| void | gvm_connection_close (gvm_connection_t *connection) |
| Close a server connection and its socket. More... | |
| int | gvm_server_attach (int socket, gnutls_session_t *session) |
| Attach a socket to a session, and shake hands with the peer. More... | |
| static int | gvm_server_vsendf_internal (gnutls_session_t *session, const char *fmt, va_list ap, int quiet) |
| Send a string to the server. More... | |
| static int | unix_vsendf_internal (int socket, const char *fmt, va_list ap, int quiet) |
| Send a string to the server. More... | |
| static int | gvm_connection_vsendf_internal (gvm_connection_t *connection, const char *fmt, va_list ap, int quiet) |
| Send a string to the connection. More... | |
| int | gvm_server_vsendf (gnutls_session_t *session, const char *fmt, va_list ap) |
| Send a string to the server. More... | |
| int | gvm_socket_vsendf (int socket, const char *fmt, va_list ap) |
| Send a string to the server. More... | |
| int | gvm_connection_vsendf (gvm_connection_t *connection, const char *fmt, va_list ap) |
| Send a string to the server. More... | |
| int | gvm_server_vsendf_quiet (gnutls_session_t *session, const char *fmt, va_list ap) |
| Send a string to the server, refraining from logging besides warnings. More... | |
| int | gvm_connection_vsendf_quiet (gvm_connection_t *connection, const char *fmt, va_list ap) |
| Send a string to the server, refraining from logging besides warnings. More... | |
| int | gvm_server_sendf (gnutls_session_t *session, const char *format,...) |
| Format and send a string to the server. More... | |
| int | gvm_connection_sendf (gvm_connection_t *connection, const char *format,...) |
| Format and send a string to the server. More... | |
| int | gvm_server_sendf_quiet (gnutls_session_t *session, const char *format,...) |
| Format and send a string to the server. More... | |
| int | gvm_connection_sendf_quiet (gvm_connection_t *connection, const char *format,...) |
| Format and send a string to the server. More... | |
| int | gvm_server_sendf_xml (gnutls_session_t *session, const char *format,...) |
| Format and send an XML string to the server. More... | |
| int | gvm_connection_sendf_xml (gvm_connection_t *connection, const char *format,...) |
| Format and send an XML string to the server. More... | |
| int | gvm_server_sendf_xml_quiet (gnutls_session_t *session, const char *format,...) |
| Format and send an XML string to the server. More... | |
| int | gvm_connection_sendf_xml_quiet (gvm_connection_t *connection, const char *format,...) |
| Format and send an XML string to the server. More... | |
| static int | server_new_gnutls_init (gnutls_certificate_credentials_t *server_credentials) |
| Initialize a server session. More... | |
| static int | server_new_gnutls_set (unsigned int end_type, const char *priority, gnutls_session_t *server_session, gnutls_certificate_credentials_t *server_credentials) |
| Set the server credencials. More... | |
| int | gvm_server_new (unsigned int end_type, gchar *ca_cert_file, gchar *cert_file, gchar *key_file, gnutls_session_t *server_session, gnutls_certificate_credentials_t *server_credentials) |
| Make a session for connecting to a server. More... | |
| int | gvm_server_new_mem (unsigned int end_type, const char *ca_cert, const char *pub_key, const char *priv_key, gnutls_session_t *session, gnutls_certificate_credentials_t *credentials) |
| Make a session for connecting to a server, with certificates stored in memory. More... | |
| int | set_gnutls_dhparams (gnutls_certificate_credentials_t creds, const char *dhparams_file) |
| Set a gnutls session's Diffie-Hellman parameters. More... | |
| int | gvm_server_free (int server_socket, gnutls_session_t server_session, gnutls_certificate_credentials_t server_credentials) |
| Cleanup a server session. More... | |
Variables | |
| struct sockaddr_in | address |
| Server address. More... | |
| static char * | cert_pub_mem = NULL |
| static char * | cert_priv_mem = NULL |
GnuTLS based functions for server communication.
This library supplies low-level communication functions for communication with a server over GnuTLS.
Definition in file serverutils.c.
| #define _GNU_SOURCE |
Definition at line 28 of file serverutils.c.
| #define G_LOG_DOMAIN "lib serv" |
GLib log domain.
Definition at line 52 of file serverutils.c.
|
static |
Callback function to be called in order to retrieve the certificate to be used in the handshake.
| [in] | session | Pointer to GNUTLS session. Not in used. Can be NULL. |
| [in] | req_ca_rdn | Contains a list with the CA names that the server considers trusted. Not in used. Can be NULL. |
| [in] | nreqs | Number of CA requested. Not in used. Can be NULL. |
| [in] | sign_algos | contains a list with server's acceptable public key algorithms. Not in used. Can be NULL. |
| [in] | sign_algos_length | Algos list length. Not in used. Can be NULL. |
| [out] | st | Should contain the certificates and private keys |
Definition at line 275 of file serverutils.c.
References get_cert_priv_mem(), and get_cert_pub_mem().
Referenced by gvm_server_open_verify().


|
static |
Close UNIX socket connection.
| [in] | client_connection | Client connection. |
Definition at line 76 of file serverutils.c.
References gvm_connection_t::socket.
Referenced by gvm_connection_free().

|
static |
Get private certificate from cert_priv_mem.
Definition at line 246 of file serverutils.c.
References cert_priv_mem.
Referenced by client_cert_callback().

|
static |
Get public certificate from cert_pub_mem.
Definition at line 256 of file serverutils.c.
References cert_pub_mem.
Referenced by client_cert_callback().

| void gvm_connection_close | ( | gvm_connection_t * | connection | ) |
Close a server connection and its socket.
| [in] | connection | Connection. |
Definition at line 520 of file serverutils.c.
References gvm_connection_free().

| void gvm_connection_free | ( | gvm_connection_t * | client_connection | ) |
Free connection.
| [in] | client_connection | Connection. |
Definition at line 111 of file serverutils.c.
References close_unix(), gvm_connection_t::credentials, gvm_server_free(), gvm_connection_t::session, gvm_connection_t::socket, and gvm_connection_t::tls.
Referenced by gvm_connection_close().


| int gvm_connection_sendf | ( | gvm_connection_t * | connection, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send a string to the server.
| [in] | connection | Connection. |
| [in] | format | printf-style format string for message. |
Definition at line 839 of file serverutils.c.
References gvm_connection_vsendf().
Referenced by gmp_ping_c(), gmp_resume_task_report_c(), gmp_start_task_report_c(), gmp_stop_task_c(), and gvm_connection_sendf_xml().


| int gvm_connection_sendf_quiet | ( | gvm_connection_t * | connection, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send a string to the server.
| [in] | connection | Connection. |
| [in] | format | printf-style format string for message. |
Definition at line 879 of file serverutils.c.
References gvm_connection_vsendf_quiet().
Referenced by gvm_connection_sendf_xml_quiet().


| int gvm_connection_sendf_xml | ( | gvm_connection_t * | connection, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send an XML string to the server.
Escape XML in string and character args.
| [in] | connection | Connection. |
| [in] | format | printf-style format string for message. |
Definition at line 927 of file serverutils.c.
References gvm_connection_sendf().

| int gvm_connection_sendf_xml_quiet | ( | gvm_connection_t * | connection, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send an XML string to the server.
Escape XML in string and character args.
Quiet version, only logs warnings.
| [in] | connection | Connection. |
| [in] | format | printf-style format string for message. |
Definition at line 981 of file serverutils.c.
References gvm_connection_sendf_quiet().
Referenced by gmp_authenticate_info_ext_c().


| int gvm_connection_vsendf | ( | gvm_connection_t * | connection, |
| const char * | fmt, | ||
| va_list | ap | ||
| ) |
Send a string to the server.
| [in] | connection | Connection. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
Definition at line 773 of file serverutils.c.
References gvm_connection_vsendf_internal().
Referenced by gvm_connection_sendf().


|
static |
Send a string to the connection.
| [in] | connection | Connection. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
| [in] | quiet | Whether to log debug and info messages. Useful for hiding passwords. |
Definition at line 725 of file serverutils.c.
References gvm_server_vsendf_internal(), gvm_connection_t::session, gvm_connection_t::socket, gvm_connection_t::tls, and unix_vsendf_internal().
Referenced by gvm_connection_vsendf(), and gvm_connection_vsendf_quiet().


| int gvm_connection_vsendf_quiet | ( | gvm_connection_t * | connection, |
| const char * | fmt, | ||
| va_list | ap | ||
| ) |
Send a string to the server, refraining from logging besides warnings.
| [in] | connection | Connection. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
Definition at line 804 of file serverutils.c.
References gvm_connection_vsendf_internal().
Referenced by gvm_connection_sendf_quiet().


| int gvm_server_attach | ( | int | socket, |
| gnutls_session_t * | session | ||
| ) |
Attach a socket to a session, and shake hands with the peer.
| [in] | socket | Socket. |
| [in] | session | Pointer to GNUTLS session. FIXME: Why is this a pointer to a session? |
Definition at line 585 of file serverutils.c.
References server_attach_internal().

| int gvm_server_close | ( | int | socket, |
| gnutls_session_t | session | ||
| ) |
Close a server connection and its socket.
| [in] | socket | Socket connected to server. |
| [in] | session | GNUTLS session with server. |
Definition at line 507 of file serverutils.c.
References gvm_server_free().
Referenced by osp_connection_close().


| int gvm_server_free | ( | int | server_socket, |
| gnutls_session_t | server_session, | ||
| gnutls_certificate_credentials_t | server_credentials | ||
| ) |
Cleanup a server session.
This shuts down the TLS session, closes the socket and releases the TLS resources.
| [in] | server_socket | The socket connected to the server. |
| [in] | server_session | The session with the server. |
| [in] | server_credentials | Credentials or NULL. |
Definition at line 1273 of file serverutils.c.
Referenced by gvm_connection_free(), and gvm_server_close().

| int gvm_server_new | ( | unsigned int | end_type, |
| gchar * | ca_cert_file, | ||
| gchar * | cert_file, | ||
| gchar * | key_file, | ||
| gnutls_session_t * | server_session, | ||
| gnutls_certificate_credentials_t * | server_credentials | ||
| ) |
Make a session for connecting to a server.
| [in] | end_type | Connection end type (GNUTLS_SERVER or GNUTLS_CLIENT). |
| [in] | ca_cert_file | Certificate authority file. |
| [in] | cert_file | Certificate file. |
| [in] | key_file | Key file. |
| [out] | server_session | The session with the server. |
| [out] | server_credentials | Server credentials. |
Definition at line 1155 of file serverutils.c.
References server_new_internal().

| int gvm_server_new_mem | ( | unsigned int | end_type, |
| const char * | ca_cert, | ||
| const char * | pub_key, | ||
| const char * | priv_key, | ||
| gnutls_session_t * | session, | ||
| gnutls_certificate_credentials_t * | credentials | ||
| ) |
Make a session for connecting to a server, with certificates stored in memory.
| [in] | end_type | Connecton end type: GNUTLS_SERVER or GNUTLS_CLIENT. |
| [in] | ca_cert | Certificate authority public key. |
| [in] | pub_key | Public key. |
| [in] | priv_key | Private key. |
| [out] | session | The session with the server. |
| [out] | credentials | Server credentials. |
Definition at line 1177 of file serverutils.c.
References server_new_gnutls_init(), and server_new_gnutls_set().
Referenced by gvm_server_open_verify().


| int gvm_server_open | ( | gnutls_session_t * | session, |
| const char * | host, | ||
| int | port | ||
| ) |
Connect to the server using a given host and port.
| [in] | session | Pointer to GNUTLS session. |
| [in] | host | Host to connect to. |
| [in] | port | Port to connect to. |
Definition at line 493 of file serverutils.c.
References gvm_server_open_with_cert().

| int gvm_server_open_verify | ( | gnutls_session_t * | session, |
| const char * | host, | ||
| int | port, | ||
| const char * | ca_mem, | ||
| const char * | pub_mem, | ||
| const char * | priv_mem, | ||
| int | verify | ||
| ) |
Connect to the server using a given host, port and cert.
| [in] | session | Pointer to GNUTLS session. |
| [in] | host | Host to connect to. |
| [in] | port | Port to connect to. |
| [in] | ca_mem | CA cert. |
| [in] | pub_mem | Public key. |
| [in] | priv_mem | Private key. |
| [in] | verify | Whether to verify. |
Definition at line 327 of file serverutils.c.
References address, client_cert_callback(), gvm_get_host_type(), gvm_server_new_mem(), gvm_server_verify(), HOST_TYPE_IPV4, HOST_TYPE_IPV6, HOST_TYPE_NAME, server_attach_internal(), set_cert_priv_mem(), and set_cert_pub_mem().
Referenced by gvm_server_open_with_cert().


| int gvm_server_open_with_cert | ( | gnutls_session_t * | session, |
| const char * | host, | ||
| int | port, | ||
| const char * | ca_mem, | ||
| const char * | pub_mem, | ||
| const char * | priv_mem | ||
| ) |
Connect to the server using a given host, port and cert.
Verify if all cert args are given.
| [in] | session | Pointer to GNUTLS session. |
| [in] | host | Host to connect to. |
| [in] | port | Port to connect to. |
| [in] | ca_mem | CA cert. |
| [in] | pub_mem | Public key. |
| [in] | priv_mem | Private key. |
Definition at line 475 of file serverutils.c.
References gvm_server_open_verify().
Referenced by gvm_server_open(), and osp_send_command().


| int gvm_server_sendf | ( | gnutls_session_t * | session, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send a string to the server.
| [in] | session | Pointer to GNUTLS session. |
| [in] | format | printf-style format string for message. |
Definition at line 819 of file serverutils.c.
References gvm_server_vsendf().
Referenced by gmp_create_lsc_credential_ext(), gmp_create_target_ext(), gmp_create_task_ext(), gmp_delete_config_ext(), gmp_delete_lsc_credential_ext(), gmp_delete_port_list_ext(), gmp_delete_report(), gmp_delete_target_ext(), gmp_delete_task(), gmp_delete_task_ext(), gmp_get_report_ext(), gmp_get_system_reports(), gmp_get_system_reports_ext(), gmp_get_targets(), gmp_get_task_ext(), gmp_get_tasks(), gmp_get_tasks_ext(), gmp_modify_task_file(), gmp_ping(), gmp_resume_task_report(), gmp_start_task_report(), gmp_stop_task(), and gvm_server_sendf_xml().


| int gvm_server_sendf_quiet | ( | gnutls_session_t * | session, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send a string to the server.
| [in] | session | Pointer to GNUTLS session. |
| [in] | format | printf-style format string for message. |
Definition at line 859 of file serverutils.c.
References gvm_server_vsendf_quiet().
Referenced by gvm_server_sendf_xml_quiet().


| int gvm_server_sendf_xml | ( | gnutls_session_t * | session, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send an XML string to the server.
Escape XML in string and character args.
| [in] | session | Pointer to GNUTLS session. |
| [in] | format | printf-style format string for message. |
Definition at line 902 of file serverutils.c.
References gvm_server_sendf().
Referenced by gmp_create_lsc_credential(), gmp_create_lsc_credential_key(), and gmp_create_task().


| int gvm_server_sendf_xml_quiet | ( | gnutls_session_t * | session, |
| const char * | format, | ||
| ... | |||
| ) |
Format and send an XML string to the server.
Escape XML in string and character args.
Quiet version, only logs warnings.
| [in] | session | Pointer to GNUTLS session. |
| [in] | format | printf-style format string for message. |
Definition at line 954 of file serverutils.c.
References gvm_server_sendf_quiet().
Referenced by gmp_authenticate(), gmp_authenticate_info_ext(), and gmp_create_lsc_credential().


| int gvm_server_verify | ( | gnutls_session_t | session | ) |
Verify certificate.
| [in] | session | Pointer to GNUTLS session. |
Definition at line 130 of file serverutils.c.
Referenced by gvm_server_open_verify().

| int gvm_server_vsendf | ( | gnutls_session_t * | session, |
| const char * | fmt, | ||
| va_list | ap | ||
| ) |
Send a string to the server.
| [in] | session | Pointer to GNUTLS session. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
Definition at line 743 of file serverutils.c.
References gvm_server_vsendf_internal().
Referenced by gvm_server_sendf().


|
static |
Send a string to the server.
| [in] | session | Pointer to GNUTLS session. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
| [in] | quiet | Whether to log debug and info messages. Useful for hiding passwords. |
Definition at line 605 of file serverutils.c.
Referenced by gvm_connection_vsendf_internal(), gvm_server_vsendf(), and gvm_server_vsendf_quiet().

| int gvm_server_vsendf_quiet | ( | gnutls_session_t * | session, |
| const char * | fmt, | ||
| va_list | ap | ||
| ) |
Send a string to the server, refraining from logging besides warnings.
| [in] | session | Pointer to GNUTLS session. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
Definition at line 789 of file serverutils.c.
References gvm_server_vsendf_internal().
Referenced by gvm_server_sendf_quiet().


| int gvm_socket_vsendf | ( | int | socket, |
| const char * | fmt, | ||
| va_list | ap | ||
| ) |
Send a string to the server.
| [in] | socket | Socket to send string through. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
Definition at line 758 of file serverutils.c.
References unix_vsendf_internal().

| int load_gnutls_file | ( | const char * | file, |
| gnutls_datum_t * | loaded_file | ||
| ) |
Loads a file's data into gnutls_datum_t struct.
| [in] | file | File to load. |
| [out] | loaded_file | Destination to load file into. |
Definition at line 180 of file serverutils.c.
Referenced by set_gnutls_dhparams().

|
static |
Attach a socket to a session, and shake hands with the peer.
| [in] | socket | Socket. |
| [in] | session | Pointer to GNUTLS session. |
| [in] | host | NULL or the name of the host for diagnostics |
| [in] | port | Port number for diagnostics; only used if host is not NULL |
Definition at line 537 of file serverutils.c.
Referenced by gvm_server_attach(), and gvm_server_open_verify().

|
static |
Initialize a server session.
| [in] | server_credentials | Credentials to be allocated. |
Definition at line 1002 of file serverutils.c.
Referenced by gvm_server_new_mem(), and server_new_internal().

|
static |
Set the server credencials.
| [in] | end_type | Connection end type. |
| [in] | priority | TLS priority to be set. If no one is given, NORMAL is default. |
| [in] | server_session | GNUTLS session. |
| [in] | server_credentials | Credentials to be set. |
Definition at line 1032 of file serverutils.c.
Referenced by gvm_server_new_mem(), and server_new_internal().

|
static |
Make a session for connecting to a server.
| [in] | end_type | Connection end type (GNUTLS_SERVER or GNUTLS_CLIENT). |
| [in] | priority | Custom priority string or NULL. |
| [in] | ca_cert_file | Certificate authority file. |
| [in] | cert_file | Certificate file. |
| [in] | key_file | Key file. |
| [out] | server_session | The session with the server. |
| [out] | server_credentials | Server credentials. |
Definition at line 1090 of file serverutils.c.
References server_new_gnutls_init(), and server_new_gnutls_set().
Referenced by gvm_server_new().


|
static |
Save cert_priv_mem with private certificate.
| [in] | data | The DER or PEM encoded certificate. |
Definition at line 234 of file serverutils.c.
References cert_priv_mem.
Referenced by gvm_server_open_verify().

|
static |
Save cert_pub_mem with public certificate.
| [in] | data | The DER or PEM encoded certificate. |
Definition at line 222 of file serverutils.c.
References cert_pub_mem.
Referenced by gvm_server_open_verify().

| int set_gnutls_dhparams | ( | gnutls_certificate_credentials_t | creds, |
| const char * | dhparams_file | ||
| ) |
Set a gnutls session's Diffie-Hellman parameters.
| [in] | creds | GnuTLS credentials. |
| [in] | dhparams_file | Path to PEM file containing the DH parameters. |
Definition at line 1239 of file serverutils.c.
References load_gnutls_file(), and unload_gnutls_file().

|
static |
Send a string to the server.
| [in] | socket | Socket. |
| [in] | fmt | Format of string to send. |
| [in] | ap | Args for fmt. |
| [in] | quiet | Whether to log debug and info messages. Useful for hiding passwords. |
Definition at line 673 of file serverutils.c.
Referenced by gvm_connection_vsendf_internal(), and gvm_socket_vsendf().

| void unload_gnutls_file | ( | gnutls_datum_t * | data | ) |
Unloads a gnutls_datum_t struct's data.
| [in] | data | Pointer to gnutls_datum_t struct to be unloaded. |
Definition at line 208 of file serverutils.c.
Referenced by set_gnutls_dhparams().

| struct sockaddr_in address |
Server address.
Definition at line 57 of file serverutils.c.
Referenced by gvm_server_open_verify().
|
static |
Definition at line 215 of file serverutils.c.
Referenced by get_cert_priv_mem(), and set_cert_priv_mem().
|
static |
Definition at line 214 of file serverutils.c.
Referenced by get_cert_pub_mem(), and set_cert_pub_mem().