Bagikan melalui


HttpBaseProtocolFilter.ServerCustomValidationRequested Kejadian

Definisi

Kejadian ini dinaikkan ketika koneksi SSL/TLS sedang dibuat dengan server. Anda harus menerapkan penanganan aktivitas untuk peristiwa ini jika Anda perlu melakukan validasi tambahan (selain default OS) dari sertifikat SSL server.

// Register
event_token ServerCustomValidationRequested(TypedEventHandler<HttpBaseProtocolFilter, HttpServerCustomValidationRequestedEventArgs const&> const& handler) const;

// Revoke with event_token
void ServerCustomValidationRequested(event_token const* cookie) const;

// Revoke with event_revoker
HttpBaseProtocolFilter::ServerCustomValidationRequested_revoker ServerCustomValidationRequested(auto_revoke_t, TypedEventHandler<HttpBaseProtocolFilter, HttpServerCustomValidationRequestedEventArgs const&> const& handler) const;
public event TypedEventHandler<HttpBaseProtocolFilter,HttpServerCustomValidationRequestedEventArgs> ServerCustomValidationRequested;
function onServerCustomValidationRequested(eventArgs) { /* Your code */ }
httpBaseProtocolFilter.addEventListener("servercustomvalidationrequested", onServerCustomValidationRequested);
httpBaseProtocolFilter.removeEventListener("servercustomvalidationrequested", onServerCustomValidationRequested);
- or -
httpBaseProtocolFilter.onservercustomvalidationrequested = onServerCustomValidationRequested;
Public Custom Event ServerCustomValidationRequested As TypedEventHandler(Of HttpBaseProtocolFilter, HttpServerCustomValidationRequestedEventArgs) 

Jenis Acara

Persyaratan Windows

Rangkaian perangkat
Windows 10 Anniversary Edition (diperkenalkan dalam 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v3.0)

Keterangan

Validasi OS default sertifikat server dilakukan sebelum menaikkan kejadian ini. Jika sertifikat gagal dalam validasi ini, koneksi dihentikan dan penanganan aktivitas Anda tidak dipanggil.

Untuk melewati bagian validasi OS (tidak disarankan untuk skenario produksi), gunakan properti IgnorableServerCertificateErrors untuk menentukan kesalahan yang ingin Anda abaikan. Kemudian selama sertifikat tidak memiliki kesalahan lain, validasi OS akan dianggap berhasil dan penanganan aktivitas Anda akan dipanggil.

Kode penanganan aktivitas dijalankan sebagai bagian dari panggilan balik sinkron di OS selama pembentukan koneksi SSL/TLS. Hindari melakukan tugas jangka panjang dalam kode penanganan aktivitas untuk mencegah server kehabisan waktu selama koneksi.

Jika Anda perlu memanggil API asinkron dalam kode penanganan aktivitas, Anda harus mengambil deferral (Lihat HttpServerCustomValidationArgs.GetDeferral) sebelum memanggil API asinkron. Setelah selesai, panggil penangguh. Metode lengkap untuk mengembalikan kontrol dari kode handler Anda.

Cuplikan berikut menunjukkan cara berlangganan acara ini.

HttpBaseProtocolFilter.ServerCustomValidationRequest += (sender, args) =>
{
	var cert = args.ServerCertificate
	// Your custom cert validation code here.
}

Berlaku untuk