0

所以我有以下代码:

SecBuffer input_buffers[2];
SecBuffer output_buffers[2];
ULONG context_attributes;

/* we need to try and perform the second (next) step of the init */
input_buffers[0].cbBuffer = tls_io_instance->received_byte_count;
input_buffers[0].BufferType = SECBUFFER_TOKEN;
input_buffers[0].pvBuffer = (void*)tls_io_instance->received_bytes;
input_buffers[1].cbBuffer = 0;
input_buffers[1].BufferType = SECBUFFER_EMPTY;
input_buffers[1].pvBuffer = 0;

SecBufferDesc input_buffers_desc;
input_buffers_desc.cBuffers = 2;
input_buffers_desc.pBuffers = input_buffers;
input_buffers_desc.ulVersion = SECBUFFER_VERSION;

output_buffers[0].cbBuffer = 0;
output_buffers[0].BufferType = SECBUFFER_TOKEN;
output_buffers[0].pvBuffer = NULL;
output_buffers[1].cbBuffer = 0;
output_buffers[1].BufferType = SECBUFFER_EMPTY;
output_buffers[1].pvBuffer = 0;

SecBufferDesc output_buffers_desc;
output_buffers_desc.cBuffers = 2;
output_buffers_desc.pBuffers = output_buffers;
output_buffers_desc.ulVersion = SECBUFFER_VERSION;

unsigned long flags = ISC_REQ_EXTENDED_ERROR | ISC_REQ_STREAM | ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_USE_SUPPLIED_CREDS;
SECURITY_STATUS status = InitializeSecurityContext(&tls_io_instance->credential_handle,
                        &tls_io_instance->security_context, (SEC_CHAR*)tls_io_instance->host_name, flags, 0, 0, 
                        &input_buffers_desc, 0,
                        &tls_io_instance->security_context, &output_buffers_desc, &context_attributes, NULL);

问题是,在Windows 8.1Windows 10平台上执行此代码后,input_buffers[1].BufferType设置为4。如果它在Windows Server 2012 R2上执行,则input_buffers[1].BufferType保持0 (SECBUFFER_MISSING)并且我最终会出错。有谁知道为什么InitializeSecurityContext (Schannel) 函数没有改变input_buffers[1]Windows Server 上的类型?

我非常感谢您能提供的任何帮助。

两个平台上返回的编辑 1 状态相同 (-2146893032),只是在 Win 8.1/10 功能更改input_buffers[1].BufferType为 4。

编辑 2 在 Win 8.1/10 上,它进入此案例选项的 else 分支,在 Win Server 2012 R2 中,它进入 if 分支。在所有平台上,状态设置为 SEC_E_INCOMPLETE_MESSAGE (-2146893032)

   switch (status)
            {
            case SEC_E_INCOMPLETE_MESSAGE:
                if (input_buffers[1].BufferType != SECBUFFER_MISSING)
                {
                    tls_io_instance->tlsio_state = TLSIO_STATE_ERROR;
                    if (tls_io_instance->on_io_open_complete != NULL)
                    {
                        tls_io_instance->on_io_open_complete(tls_io_instance->open_callback_context, IO_OPEN_ERROR);
                    }
                }
                else
                {
                    tls_io_instance->needed_bytes = input_buffers[1].cbBuffer;
                    tls_io_instance->consumed_bytes += tls_io_instance->needed_bytes;
                    if (resize_receive_buffer(tls_io_instance, tls_io_instance->received_byte_count + tls_io_instance->needed_bytes) != 0)
                    {
                        tls_io_instance->tlsio_state = TLSIO_STATE_ERROR;
                        if (tls_io_instance->on_io_open_complete != NULL)
                        {
                            tls_io_instance->on_io_open_complete(tls_io_instance->open_callback_context, IO_OPEN_ERROR);
                        }
                    }
                }
4

1 回答 1

0

好的,所以我联系了创建者,看来这是他们实用程序库代码中的一个错误,他们在实用程序库的开发人员分支中修复了它,他们正在对其进行测试。谢谢大家的回复!

于 2016-10-21T14:30:10.643 回答