Ejemplo n.º 1
0
ret_t
cherokee_validator_file_configure (cherokee_config_node_t     *conf,
				   cherokee_server_t          *srv,
				   cherokee_module_props_t  **_props)
{
	ret_t                            ret;
	cherokee_config_node_t          *subconf;
	cherokee_validator_file_props_t *props    = PROP_VFILE(*_props);

	UNUSED (srv);

	/* Password file
	 */
	ret = cherokee_config_node_get (conf, "passwdfile", &subconf);
	if (ret == ret_ok) {
		cherokee_buffer_add_buffer (&props->password_file, &subconf->val);
	}

	/* Path type
	 */
	ret = cherokee_config_node_get (conf, "passwdfile_path", &subconf);
	if (ret == ret_ok) {
		if (equal_buf_str (&subconf->val, "full")) {
			props->password_path_type = val_path_full;
		} else if (equal_buf_str (&subconf->val, "local_dir")) {
			props->password_path_type = val_path_local_dir;
		} else {
			LOG_ERROR (CHEROKEE_ERROR_VALIDATOR_FILE, subconf->val.buf);
			return ret_error;
		}
	}

	/* Final checks
	 */
	if (cherokee_buffer_is_empty (&props->password_file)) {
		LOG_CRITICAL_S (CHEROKEE_ERROR_VALIDATOR_FILE_NO_FILE);
		return ret_error;
	}

	return ret_ok;
}
Ejemplo n.º 2
0
ret_t
cherokee_handler_secdownload_configure (cherokee_config_node_t   *conf,
					cherokee_server_t        *srv,
					cherokee_module_props_t **_props)
{
	ret_t                                 ret;
	cherokee_handler_secdownload_props_t *props;

	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_secdownload_props);

		cherokee_handler_props_init_base (HANDLER_PROPS(n),
			MODULE_PROPS_FREE(cherokee_handler_secdownload_props_free));

		cherokee_buffer_init (&n->secret);
		n->timeout = 60;

		*_props = MODULE_PROPS(n);
	}

	props = PROP_SECDOWN(*_props);

	/* Parse 'file' parameters
	 */
	props->props_file = NULL;
	ret = cherokee_handler_file_configure (conf, srv, (cherokee_module_props_t **)&props->props_file);
	if ((ret != ret_ok) && (ret != ret_deny))
		return ret;

	/* Properties
	 */
	ret = cherokee_config_node_copy (conf, "secret", &props->secret);
	if (ret != ret_ok) {
		LOG_CRITICAL_S (CHEROKEE_ERROR_HANDLER_SECDOWN_SECRET);
		return ret_error;
	}

	cherokee_config_node_read_int (conf, "timeout", (int*)&props->timeout);

	return ret_ok;
}
Ejemplo n.º 3
0
ret_t
http2d_init (void)
{
	if (_initialized)
		return ret_ok;

        /* Init OpenSSL
         */
        OPENSSL_config (NULL);
        SSL_library_init();
        SSL_load_error_strings();
        OpenSSL_add_all_algorithms();

        /* Ensure PRNG has been seeded with enough data
         */
        if (RAND_status() == 0) {
                LOG_WARNING_S (HTTP2D_ERROR_SSL_NO_ENTROPY);
        }

        /* Init concurrency related stuff
         */
        if ((CRYPTO_get_id_callback()      == NULL) &&
            (CRYPTO_get_locking_callback() == NULL))
        {
                cuint_t n;

                CRYPTO_set_id_callback (__get_thread_id);
                CRYPTO_set_locking_callback (__lock_thread);

                locks_num = CRYPTO_num_locks();
                locks     = malloc (locks_num * sizeof(*locks));

                for (n = 0; n < locks_num; n++) {
                        HTTP2D_MUTEX_INIT (&locks[n], NULL);
                }
        }

	/* Engines
	 */
        ENGINE_load_builtin_engines();
        OpenSSL_add_all_algorithms();

        ENGINE *e = ENGINE_by_id("pkcs11");
        while (e != NULL) {
                if(! ENGINE_init(e)) {
                        ENGINE_free (e);
                        LOG_CRITICAL_S (HTTP2D_ERROR_SSL_PKCS11);
                        break;
                }

                if(! ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
                        ENGINE_free (e);
                        LOG_CRITICAL_S (HTTP2D_ERROR_SSL_DEFAULTS);
                        break;
                }

                ENGINE_finish(e);
                ENGINE_free(e);
                break;
        }

	return ret_ok;
}