Neo4j-Client

 view release on metacpan or  search on metacpan

build/lib/src/client_config.c  view on Meta::CPAN

    if (strdup_null(&(dup->username), config->username))
    {
        goto failure;
    }
    if (strdup_null(&(dup->password), config->password))
    {
        goto failure;
    }

#ifdef HAVE_TLS
    if (strdup_null(&(dup->tls_private_key_file), config->tls_private_key_file))
    {
        goto failure;
    }
    if (strdup_null(&(dup->tls_ca_file), config->tls_ca_file))
    {
        goto failure;
    }
    if (strdup_null(&(dup->tls_ca_dir), config->tls_ca_dir))
    {
        goto failure;

build/lib/src/client_config.c  view on Meta::CPAN


void neo4j_config_free(neo4j_config_t *config)
{
    if (config == NULL)
    {
        return;
    }
    ignore_unused_result(neo4j_config_set_username(config, NULL));
    ignore_unused_result(neo4j_config_set_password(config, NULL));
#ifdef HAVE_TLS
    ignore_unused_result(neo4j_config_set_TLS_private_key(config, NULL));
    ignore_unused_result(neo4j_config_set_TLS_ca_file(config, NULL));
    ignore_unused_result(neo4j_config_set_TLS_ca_dir(config, NULL));
#endif
    ignore_unused_result(neo4j_config_set_known_hosts_file(config, NULL));
    free(config);
}


void neo4j_config_set_client_id(neo4j_config_t *config, const char *client_id)
{

build/lib/src/client_config.c  view on Meta::CPAN

int neo4j_config_set_basic_auth_callback(neo4j_config_t *config,
        neo4j_basic_auth_callback_t callback, void *userdata)
{
    REQUIRE(config != NULL, -1);
    config->basic_auth_callback = callback;
    config->basic_auth_callback_userdata = userdata;
    return 0;
}


int neo4j_config_set_TLS_private_key(neo4j_config_t *config, const char *path)
{
    REQUIRE(config != NULL, -1);
#ifdef HAVE_TLS
    return replace_strptr_dup(&(config->tls_private_key_file), path);
#else
    errno = NEO4J_TLS_NOT_SUPPORTED;
    return -1;
#endif
}

const char *neo4j_config_get_TLS_private_key(const neo4j_config_t *config)
{
    REQUIRE(config != NULL, NULL);
#ifdef HAVE_TLS
    return config->tls_private_key_file;
#else
    return NULL;
#endif
}


int neo4j_config_set_TLS_private_key_password_callback(neo4j_config_t *config,
        neo4j_password_callback_t callback, void *userdata)
{
    REQUIRE(config != NULL, -1);
#ifdef HAVE_TLS
    config->tls_pem_pw_callback = callback;
    config->tls_pem_pw_callback_userdata = userdata;
    return 0;
#else
    errno = NEO4J_TLS_NOT_SUPPORTED;
    return -1;
#endif
}


int neo4j_config_set_TLS_private_key_password(neo4j_config_t *config,
        const char *password)
{
    REQUIRE(config != NULL, -1);
    return neo4j_config_set_TLS_private_key_password_callback(config,
            default_password_callback, (void *)(intptr_t)password);
}


int neo4j_config_set_TLS_ca_file(neo4j_config_t *config, const char *path)
{
    REQUIRE(config != NULL, -1);
#ifdef HAVE_TLS
    return replace_strptr_dup(&(config->tls_ca_file), path);
#else

build/lib/src/client_config.h  view on Meta::CPAN

    size_t io_rcvbuf_size;
    size_t io_sndbuf_size;

    uint16_t snd_min_chunk_size;
    uint16_t snd_max_chunk_size;

    unsigned int session_request_queue_size;
    unsigned int max_pipelined_requests;

#ifdef HAVE_TLS
    char *tls_private_key_file;
    neo4j_password_callback_t tls_pem_pw_callback;
    void *tls_pem_pw_callback_userdata;
    char *tls_ca_file;
    char *tls_ca_dir;
#endif

    bool trust_known;
    char *known_hosts_file;

    neo4j_unverified_host_callback_t unverified_host_callback;

build/lib/src/neo4j-client.h  view on Meta::CPAN

/**
 * Set the location of a TLS private key and certificate chain.
 *
 * @param [config] The neo4j client configuration to update.
 * @param [path] The path to the PEM file containing the private key
 *         and certificate chain. The string will be
 *         duplicated, and thus may point to temporary memory.
 * @return 0 on success, or -1 on error (errno will be set).
 */
__neo4j_must_check
int neo4j_config_set_TLS_private_key(neo4j_config_t *config,
        const char *path);

/**
 * Obtain the path to the TLS private key and certificate chain.
 *
 * @param [config] The neo4j client configuration.
 * @return The path set in the config, or `NULL` if none.
 */
const char *neo4j_config_get_TLS_private_key(const neo4j_config_t *config);

/**
 * Set the password callback for the TLS private key file.
 *
 * @param [config] The neo4j client configuration to update.
 * @param [callback] The callback to be invoked whenever a password for
 *         the certificate file is required.
 * @param [userdata] User data that will be supplied to the callback.
 * @return 0 on success, or -1 on error (errno will be set).
 */
__neo4j_must_check
int neo4j_config_set_TLS_private_key_password_callback(neo4j_config_t *config,
        neo4j_password_callback_t callback, void *userdata);

/**
 * Set the password for the TLS private key file.
 *
 * This is a simpler alternative to using
 * neo4j_config_set_TLS_private_key_password_callback().
 *
 * @param [config] The neo4j client configuration to update.
 * @param [password] The password for the certificate file. This string should
 *         remain allocated whilst the config is allocated _or if any
 *         connections opened with the config remain active_.
 * @return 0 on success, or -1 on error (errno will be set).
 */
__neo4j_must_check
int neo4j_config_set_TLS_private_key_password(neo4j_config_t *config,
        const char *password);

/**
 * Set the location of a file containing TLS certificate authorities (and CRLs).
 *
 * The file should contain the certificates of the trusted CAs and CRLs. The
 * file must be in base64 privacy enhanced mail (PEM) format.
 *
 * @param [config] The neo4j client configuration to update.
 * @param [path] The path to the PEM file containing the trusted CAs and CRLs.

build/lib/src/neo4j-client.h.in  view on Meta::CPAN

/**
 * Set the location of a TLS private key and certificate chain.
 *
 * @param [config] The neo4j client configuration to update.
 * @param [path] The path to the PEM file containing the private key
 *         and certificate chain. The string will be
 *         duplicated, and thus may point to temporary memory.
 * @return 0 on success, or -1 on error (errno will be set).
 */
__neo4j_must_check
int neo4j_config_set_TLS_private_key(neo4j_config_t *config,
        const char *path);

/**
 * Obtain the path to the TLS private key and certificate chain.
 *
 * @param [config] The neo4j client configuration.
 * @return The path set in the config, or `NULL` if none.
 */
const char *neo4j_config_get_TLS_private_key(const neo4j_config_t *config);

/**
 * Set the password callback for the TLS private key file.
 *
 * @param [config] The neo4j client configuration to update.
 * @param [callback] The callback to be invoked whenever a password for
 *         the certificate file is required.
 * @param [userdata] User data that will be supplied to the callback.
 * @return 0 on success, or -1 on error (errno will be set).
 */
__neo4j_must_check
int neo4j_config_set_TLS_private_key_password_callback(neo4j_config_t *config,
        neo4j_password_callback_t callback, void *userdata);

/**
 * Set the password for the TLS private key file.
 *
 * This is a simpler alternative to using
 * neo4j_config_set_TLS_private_key_password_callback().
 *
 * @param [config] The neo4j client configuration to update.
 * @param [password] The password for the certificate file. This string should
 *         remain allocated whilst the config is allocated _or if any
 *         connections opened with the config remain active_.
 * @return 0 on success, or -1 on error (errno will be set).
 */
__neo4j_must_check
int neo4j_config_set_TLS_private_key_password(neo4j_config_t *config,
        const char *password);

/**
 * Set the location of a file containing TLS certificate authorities (and CRLs).
 *
 * The file should contain the certificates of the trusted CAs and CRLs. The
 * file must be in base64 privacy enhanced mail (PEM) format.
 *
 * @param [config] The neo4j client configuration to update.
 * @param [path] The path to the PEM file containing the trusted CAs and CRLs.

build/lib/src/openssl.c  view on Meta::CPAN

static neo4j_mutex_t *thread_locks;

#ifndef HAVE_ASN1_STRING_GET0_DATA
#define ASN1_STRING_get0_data(x) ASN1_STRING_data(x)
#endif

#ifdef HAVE_CRYPTO_SET_LOCKING_CALLBACK
static void locking_callback(int mode, int type, const char *file, int line);
#endif
static SSL_CTX *new_ctx(const neo4j_config_t *config, neo4j_logger_t *logger);
static int load_private_key(SSL_CTX *ctx, const neo4j_config_t *config,
        neo4j_logger_t *logger);
static int pem_pw_callback(char *buf, int size, int rwflag, void *userdata);
static int load_certificate_authorities(SSL_CTX *ctx,
        const neo4j_config_t *config, neo4j_logger_t *logger);
static int verify(SSL *ssl, const char *hostname, int port,
        const neo4j_config_t *config, uint_fast32_t flags,
        neo4j_logger_t *logger);
static int cert_fingerprint(X509* cert, char *buf, size_t n,
        neo4j_logger_t *logger);
static int sha512_digest(unsigned char *buf, unsigned int *np,

build/lib/src/openssl.c  view on Meta::CPAN

        errno = openssl_error(logger, NEO4J_LOG_ERROR, __FILE__, __LINE__);
        goto failure;
    }

    // Necessary when using blocking sockets
    SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);

    // Caching should be done at the protocol layer anyway
    SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);

    if (load_private_key(ctx, config, logger))
    {
        goto failure;
    }

    if (load_certificate_authorities(ctx, config, logger))
    {
        goto failure;
    }

    return ctx;

    int errsv;
failure:
    errsv = errno;
    SSL_CTX_free(ctx);
    errno = errsv;
    return NULL;
}


int load_private_key(SSL_CTX *ctx, const neo4j_config_t *config,
        neo4j_logger_t *logger)
{
    const char *private_key = config->tls_private_key_file;
    if (private_key == NULL)
    {
        return 0;
    }

    if (SSL_CTX_use_certificate_chain_file(ctx, private_key) != 1)
    {
        errno = openssl_error(logger, NEO4J_LOG_ERROR, __FILE__, __LINE__);
        return -1;
    }

    if (config->tls_pem_pw_callback != NULL)
    {
        SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *)(intptr_t)config);
        SSL_CTX_set_default_passwd_cb(ctx, pem_pw_callback);
    }



( run in 0.261 second using v1.01-cache-2.11-cpan-4d50c553e7e )