I've never used delegates before but understand the basic concept after I've been struggling for the past 2 hours. I've created a simple SSL Client/Server with mutual authentication. Now my actual problem:
In the example a delegate is used to authenticate the server/client.
SslStream sslStream = new SslStream(
client.GetStream(),
false,
new RemoteCertificateValidationCallback (ValidateServerCertificate),
null
);
The ValidateServerCertificate is the method which is run when the delegate is invoked.
public static bool ValidateServerCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors == SslPolicyErrors.None)
return true;
Console.WriteLine("Certificate error: {0}", sslPolicyErrors);
// Do not allow this client to communicate with unauthenticated servers.
return false;
}
The thing that confuses me more than anything is how in the hell the ValidateServerCertificate is getting the parameters. Maybe this is a stupid question and you are laughing right now but please bear with me. I've been sitting in front of tutorials and explanations for the past hours and I've found nothing which helped me.
Thanks in advance