Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 4.54 KB

ihttprequest-getclientcertificate-method.md

File metadata and controls

64 lines (47 loc) · 4.54 KB
title description ms.date ms.assetid
IHttpRequest::GetClientCertificate Method
Describes the IHttpRequest::GetClientCertificate method and provides the method's syntax, parameters, return value, remarks, an example, and requirements.
10/07/2016
e75ebc13-a6b4-968c-8f0b-729ba591a57b

IHttpRequest::GetClientCertificate Method

Retrieves the client certificate associated with the request.

Syntax

HRESULT GetClientCertificate(  
   OUT HTTP_SSL_CLIENT_CERT_INFO** ppClientCertInfo,  
   OUT BOOL* pfClientCertNegotiated  
);  

Parameters

ppClientCertInfo
[OUT] A pointer to an HTTP_SSL_CLIENT_CERT_INFO structure.

pfClientCertNegotiated
[OUT] true if the client certificate has been negotiated already; otherwise, false. For more information, see the Remarks section.

Return Value

An HRESULT. Possible values include, but are not limited to, those in the following table.

Value Definition
S_OK Indicates that no error occurred, but does not guarantee that a certificate was found. For more information, see the Remarks section.
HRESULT_FROM_WIN32(ERROR_NOT_FOUND) Indicates no client certificate was found. ERROR_NOT_FOUND is defined in Winerror.h.
ERROR_INVALID_PARAMETER Indicates that the ppClientCertInfo or pfClientCertNegotiated parameter is NULL.

Remarks

A successful HRESULT does not guarantee that a client certificate was found. Developers must also verify that ppClientCertInfo is not NULL.

A pfClientCertNegotiated value of true does not guarantee that the ppClientCertInfo is not NULL.

Developers can use the GetClientCertificate method to retrieve the client certificate associated with the current request. After you call the GetClientCertificate method, the ppClientCertInfo parameter will contain a pointer to an HTTP_SSL_CLIENT_CERT_INFO structure, which will contain the client certificate if one is available or NULL if no certificate is available.

For URLs that do not require a client certificate, you can call the NegotiateClientCertificate method before you call GetClientCertificate to attempt a manual loading of the client certificate.

Example

The following example demonstrates how to get a pointer to the HTTP_SSL_CLIENT_CERT_INFO structure by implementing the CHttpModule::OnBeginRequest method.

[!code-cppIHttpRequestGetClientCertificate#2]

For more information about how to create and deploy a native DLL module, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.

You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.

Requirements

Type Description
Client - IIS 7.0 on [!INCLUDEwinvista]
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on [!INCLUDEwinsrv2008]
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100]
Header Httpserv.h

See Also

IHttpRequest Interface
IHttpRequest::NegotiateClientCertificate Method