具有不同方案的同一站点上的不同证书subjectAltName

Hee,

After a lot of trial and error to read certificates data to display the information. My use case is google.nl to read the certificate with chains.

My current issue is the difference between different scheme on the google domain results on different subjectAltNames. What i wan't to fix is a code to read the same certificate information as browser gives on display certificate information details on every website i requested.

My current testcode:

<?php
$url = "https://www.google.nl";
$orignal_parse = parse_url($url, PHP_URL_HOST);
$get = stream_context_create([
        "ssl" => [
            'capture_peer_cert' => true,
            'capture_peer_cert_chain' => true,
            'disable_compression' => true
        ]
    ]);
$read = stream_socket_client("ssl://".$orignal_parse.":443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $get);
$cert = stream_context_get_params($read);
$certinfo = openssl_x509_parse($cert['options']['ssl']['peer_certificate']);

echo '<pre>';
print_r($certinfo);

The result of subjectAltNames in the code above is;

[subjectAltName] => DNS:.google.com, DNS:.android.com, DNS:.appengine.google.com, DNS:.cloud.google.com, DNS:.db833953.google.cn, DNS:.g.co, DNS:.gcp.gvt2.com, DNS:.ggpht.cn, DNS:.google-analytics.com, DNS:.google.ca, DNS:.google.cl, DNS:.google.co.in, DNS:.google.co.jp, DNS:.google.co.uk, DNS:.google.com.ar, DNS:.google.com.au, DNS:.google.com.br, DNS:.google.com.co, DNS:.google.com.mx, DNS:.google.com.tr, DNS:.google.com.vn, DNS:.google.de, DNS:.google.es, DNS:.google.fr, DNS:.google.hu, DNS:.google.it, DNS:.google.nl, DNS:.google.pl, DNS:.google.pt, DNS:.googleadapis.com, DNS:.googleapis.cn, DNS:.googlecommerce.com, DNS:.googlevideo.com, DNS:.gstatic.cn, DNS:.gstatic.com, DNS:.gstaticcnapps.cn, DNS:.gvt1.com, DNS:.gvt2.com, DNS:.metric.gstatic.com, DNS:.urchin.com, DNS:.url.google.com, DNS:.youtube-nocookie.com, DNS:.youtube.com, DNS:.youtubeeducation.com, DNS:.yt.be, DNS:.ytimg.com, DNS:android.clients.google.com, DNS:android.com, DNS:developer.android.google.cn, DNS:developers.android.google.cn, DNS:g.co, DNS:ggpht.cn, DNS:goo.gl, DNS:google-analytics.com, DNS:google.com, DNS:googlecommerce.com, DNS:source.android.google.cn, DNS:urchin.com, DNS:www.goo.gl, DNS:youtu.be, DNS:youtube.com, DNS:youtubeeducation.com, DNS:yt.be

If you change $url to https://google.nl the result of the subjectAltNames will change to;

[subjectAltName] => DNS:*.google.nl, DNS:google.nl

What i like to get is the right result same as the browser information displays when you clicked on the certificate information details.

On OSX in Safari browser you see the list of the first result.

Thanks!