TLS Enable / Disable не работает с Freeradius в качестве клиента LDAP - PullRequest
0 голосов
/ 20 июня 2019

Я использую FreeRadius 3.16 в качестве прокси-клиента. У меня есть сценарий, в котором я хочу пройти аутентификацию с использованием AD и LDAP-сервера. Сервер AD включен TLS, и аутентификация проходит через соединение TLS. Теперь я изменяю сервер на не TLS LDAP и попробуй аутентифицировать. Хотя TLS отключен, клиент пытается TLS и выдает ошибку TLS не может подключиться.

Я попытался освободить дескрипторы соединения. Только перезапуск процесса radiusd делает вызов LDAP без TLS. После того, как я снова попробую TLS, затем поменяю сервер, последующие вызовы попробуют TLS.

Поскольку TLS отключен для второго сервера, код FreeRadius не должен пытаться подключиться через TLS. Вызовы должны быть без TLS для сервера, для которого TLS не включен.

Код, как показано ниже,

#if def HAVE_LDAP_START_TLS_S
    /*
     *  Set all of the TLS options
     */
    if (inst->tls_mode) {
        do_ldap_option(LDAP_OPT_X_TLS, "tls_mode", &(inst->tls_mode));
    }

    maybe_ldap_option(LDAP_OPT_X_TLS_CACERTFILE, "ca_file", inst->tls_ca_file);
    maybe_ldap_option(LDAP_OPT_X_TLS_CACERTDIR, "ca_path", inst->tls_ca_path);


    /*
     *  Set certificate options
     */
    maybe_ldap_option(LDAP_OPT_X_TLS_CERTFILE, "certificate_file", inst->tls_certificate_file);
    maybe_ldap_option(LDAP_OPT_X_TLS_KEYFILE, "private_key_file", inst->tls_private_key_file);

#  ifdef LDAP_OPT_X_TLS_NEVER
    if (inst->tls_require_cert_str) {
        do_ldap_option(LDAP_OPT_X_TLS_REQUIRE_CERT, "require_cert", &inst->tls_require_cert);
    }
#  endif

    /*
     *  Counter intuitively the TLS context appears to need to be initialised
     *  after all the TLS options are set on the handle.
     */
#  ifdef LDAP_OPT_X_TLS_NEWCTX
    {
        /* Always use the new TLS configuration context */
        int is_server = 0;
        do_ldap_option(LDAP_OPT_X_TLS_NEWCTX, "new TLS context", &is_server);

    }
#  endif

    /*
     *  And finally start the TLS code.
     */
    if (inst->start_tls) {
        if (inst->port == 636) {
            WARN("Told to Start TLS on LDAPS port this will probably fail, please correct the "
                 "configuration");
        }

        if (ldap_start_tls_s(conn->handle, NULL, NULL) != LDAP_SUCCESS) {
            ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER, &ldap_errno);

            LDAP_ERR("Could not start TLS: %s", ldap_err2string(ldap_errno));
            goto error;
        }
    }
#endif /* HAVE_LDAP_START_TLS_S */
...