Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Inicia la negociación de certificados de cliente con un cliente web.
Sintaxis
HRESULT NegotiateClientCertificate(
IN BOOL fAsync,
OUT BOOL* pfCompletionPending = NULL
)
Parámetros
fAsync
[IN] true para especificar que la negociación debe producirse de forma asincrónica; de lo contrario, false.
pfCompletionPending
[OUT] true para especificar que una finalización asincrónica está pendiente; de lo contrario, false.
Valor devuelto
Una clase HRESULT. Entre los valores posibles se incluyen los que se indican en la tabla siguiente, entre otros.
| Value | Definición |
|---|---|
| S_OK | Indica que la operación se realizó correctamente. |
| E_FAIL | Indica que se produjo un error en la operación. |
Comentarios
Los desarrolladores pueden usar el NegotiateClientCertificate método para iniciar manualmente la negociación de certificados de cliente con un cliente web, incluso si IIS está configurado para aceptar o omitir los certificados de cliente. NegotiateClientCertificate admite la operación sincrónica y asincrónica especificando la configuración adecuada en el fAsync parámetro . Cuando el módulo llama NegotiateClientCertificate de forma asincrónica, el módulo debe devolver el procesamiento a la canalización integrada de procesamiento de solicitudes inmediatamente después de llamar al método si el pfCompletionPending valor indica que está pendiente una finalización asincrónica.
Ejemplo
En el ejemplo siguiente se muestra cómo llamar NegotiateClientCertificate al método .
REQUEST_NOTIFICATION_STATUS
CMyHttpModule::OnBeginRequest(
IHttpContext* pHttpContext,
IHttpEventProvider* // pProvider
)
{
static long cnt;
InterlockedIncrement (&cnt); // keep track of how many times we are called
HRESULT hr = E_FAIL;
IHttpRequest *pIHTTPR = pHttpContext->GetRequest();
HTTP_REQUEST * pRawRequest = pIHTTPR->GetRawHttpRequest();
HTTP_COOKED_URL hcu = pRawRequest->CookedUrl;
// Send URL and count to the trace window
TRC_MSGW_FULL( L"cnt = " << cnt << " URI: " << hcu.pFullUrl );
// return immediately if not a HTTPS request
if ( pRawRequest->pSslInfo == NULL ){
TRC_MSG( "connection is not using SSL");
return RQ_NOTIFICATION_CONTINUE;
}
// change the bForce flag to test behavior of forcing load of client cert
bool bForce=true;
if(bForce){
TRC_MSG("forcing load of client cert");
hr = pIHTTPR->NegotiateClientCertificate(FALSE);
if(FAILED(hr)){
LOG_ERR_HR(hr, "NegotiateClientCertificate : HR = ");
return RQ_NOTIFICATION_CONTINUE;
}
}
else
TRC_MSG("Not forcing load of client cert");
HTTP_SSL_CLIENT_CERT_INFO *pClientCertInfo;
BOOL fccNeg;
hr = pIHTTPR->GetClientCertificate(&pClientCertInfo,&fccNeg);
// If you have not selected "Require Client Certificates" or called
// NegotiateClientCertificate(), you may get ERROR_NOT_FOUND
if( hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND)){
TRC_MSG( "Cert not found" );
return RQ_NOTIFICATION_CONTINUE;
}
if(FAILED(hr)){
LOG_ERR_HR("GetClientCertificate", hr);
return RQ_NOTIFICATION_CONTINUE;
}
if( fccNeg && pClientCertInfo != NULL){
ULONG uSiz = pClientCertInfo->CertEncodedSize;
TRC_MSG( "cert size: " << uSiz \
<< " Previously negotiated " << fccNeg );
unsigned long certCrc = genCRC(pClientCertInfo->pCertEncoded,
pClientCertInfo->CertEncodedSize);
TRC_MSG( "cert crc: " << certCrc );
}
else
TRC_MSG( "No client certificate.");
return RQ_NOTIFICATION_CONTINUE;
}
Para obtener más información sobre cómo crear e implementar un módulo DLL nativo, consulte Tutorial: Creación de un módulo HTTP de Request-Level mediante código nativo.
Opcionalmente, puede compilar el código mediante la __stdcall (/Gz) convención de llamada en lugar de declarar explícitamente la convención de llamada para cada función.
Requisitos
| Tipo | Descripción |
|---|---|
| Remoto | - IIS 7.0 en Windows Vista - IIS 7.5 en Windows 7 - IIS 8.0 en Windows 8 - IIS 10.0 en Windows 10 |
| Servidor | - IIS 7.0 en Windows Server 2008 - IIS 7.5 en Windows Server 2008 R2 - IIS 8.0 en Windows Server 2012 - IIS 8.5 en Windows Server 2012 R2 - IIS 10.0 en Windows Server 2016 |
| Producto | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - IIS Express 7.5, IIS Express 8.0, IIS Express 10.0 |
| Encabezado | Httpserv.h |
Consulte también
IHttpRequest (interfaz)
IHttpRequest::GetClientCertificate (Método)