Zum Inhalt springen

Custom certificate validation (ARCH307)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key dotnet.security.custom-certificate-validation · Severity error · Category security · CWE CWE-295

Overriding certificate validation with a callback that returns true accepts every TLS certificate, enabling man-in-the-middle attacks.

var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback =
(msg, cert, chain, errors) => true
};
var handler = new HttpClientHandler();
// Default validation is used; trust the system certificate store.

Remove custom validation callbacks and rely on the platform’s default chain validation; if pinning is truly required, validate the chain and errors instead of returning true.