Note that there are some explanatory texts on larger screens.

plurals
  1. POC# client authenticate 2 Certificates?
    primarykey
    data
    text
    <p>I live in Israel , Google also has <code>google.co.il</code>.</p> <p>I created a webrequest to <strong>google.com</strong> ( And I want to connect <em>only</em> to google.com !)</p> <p>But in the <code>ServerCertificateValidationCallback</code> function , it seems I'm getting <em>2</em> certificates .</p> <p>Here is the code : </p> <pre><code>ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, policyError) =&gt; { var subject = ((X509Certificate2)certificate).GetName(); Console.WriteLine(subject); // return true; return XXX==YYY; // ????the 2'nd question is about this line }; WebRequest oRequest; WebResponse oResponse; oRequest = WebRequest.Create("https://www.google.com/"); oResponse = oRequest.GetResponse(); </code></pre> <p>the result for the code (when <code>return true</code> ) is <em>enabled</em> is : </p> <pre><code>C=US, S=California, L=Mountain View, O=Google Inc, CN=www.google.com C=US, S=California, L=Mountain View, O=Google Inc, CN=*.google.co.il </code></pre> <p>But Im facing a problem : </p> <p>Now that it emits 2 certificates :</p> <ol> <li><p>Why do I get 2 certifictes ? </p></li> <li><p>which value should be in "<code>XXX</code>" and which value whould be in "<code>YYY</code>" ?</p> <p>( I mean , should I equate <code>CN</code> or <code>O</code> or <em>_</em>_ to the corresponding Google's value ?</p> <p>and what if I get (firstly) the google.com certificate (which is the desired) , and later I get the google.co.il certificate ( which is <em>not</em> desired) ? </p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COEither the server sends two certificates or you are redirected to another server (which is more likely). The question is whether you need to perform validation the way you are trying to do it. Doesn't .NET Framework performs validation itself? (I have no experience with .NET built-in classes for HTTPS). If it doesn't, then validation becomes a tricky and complicated procedure which is not just comparing X to Y but performing a bunch of cryptographic operations, sending OCSP and CRL requests etc. .
      singulars
    2. CO@EugeneMayevski'EldoSCorp Thanks for reply. it seems that .net does do it ( from msdn :)=> _the certificate name is compared with host name used to create the request. For example, if Create(String) was passed a parameter of "https://www.contoso.com/default.hmtl", the default behavior is for the client to check the certificate against www.contoso.com._ So i guess it compare the `CN`. but If i'm being redirected to .co.il , Hoe can I remember That I was google.com has already been verified ?
      singulars
    3. CO(1) Why would you need to remember this? .NET automatic validation saves you from any manual comparison, and (2) isn't there some redirection notification event/callback available which lets you track the redirection?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload