Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Memulai negosiasi sertifikat klien dengan klien Web.
Sintaks
HRESULT NegotiateClientCertificate(
IN BOOL fAsync,
OUT BOOL* pfCompletionPending = NULL
)
Parameter
fAsync
[IN] true untuk menentukan bahwa negosiasi harus terjadi secara asinkron; jika tidak, false.
pfCompletionPending
[OUT] true untuk menentukan bahwa penyelesaian asinkron tertunda; jika tidak, false.
Tampilkan Nilai
Sebuah HRESULT. Nilai yang mungkin termasuk, tetapi tidak terbatas pada, yang ada dalam tabel berikut.
| Nilai | Definisi |
|---|---|
| S_OK | Menunjukkan bahwa operasi berhasil. |
| E_FAIL | Menunjukkan bahwa operasi gagal. |
Keterangan
Pengembang dapat menggunakan NegotiateClientCertificate metode untuk memulai negosiasi sertifikat klien secara manual dengan klien Web, bahkan jika IIS dikonfigurasi untuk menerima atau mengabaikan sertifikat klien. NegotiateClientCertificate mendukung operasi sinkron dan asinkron dengan menentukan pengaturan yang sesuai dalam fAsync parameter . Saat modul Anda memanggil NegotiateClientCertificate secara asinkron, modul harus mengembalikan pemrosesan ke alur pemrosesan permintaan terintegrasi segera setelah memanggil metode jika pfCompletionPending nilai menunjukkan bahwa penyelesaian asinkron tertunda.
Contoh
Contoh berikut menunjukkan cara memanggil NegotiateClientCertificate metode.
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;
}
Untuk informasi selengkapnya tentang cara membuat dan menyebarkan modul DLL asli, lihat Panduan: Membuat Modul HTTP Request-Level Dengan Menggunakan Kode Asli.
Anda dapat secara opsional mengkompilasi kode dengan menggunakan __stdcall (/Gz) konvensi panggilan alih-alih secara eksplisit mendeklarasikan konvensi panggilan untuk setiap fungsi.
Persyaratan
| Jenis | Deskripsi |
|---|---|
| Klien | - IIS 7.0 di Windows Vista - IIS 7.5 di Windows 7 - IIS 8.0 di Windows 8 - IIS 10.0 pada Windows 10 |
| Server | - IIS 7.0 di Windows Server 2008 - IIS 7.5 di Windows Server 2008 R2 - IIS 8.0 di Windows Server 2012 - IIS 8.5 di Windows Server 2012 R2 - IIS 10.0 di Windows Server 2016 |
| Produk | - 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 |
| Header | Httpserv.h |
Lihat juga
Antarmuka IHttpRequest
Metode IHttpRequest::GetClientCertificate