• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Question Plesk API - retrieve attributes of SSL certificate for domain

Oleksander

New Pleskian
Hi, All!

Please help - I can't retrieve SSL-certificete attributes through Plesk API.

I run request XML request:
<packet>
<certificate>
<get-pool>
<filter>

<domain-name>your-domain-name.com</domain-name>
</filter>
</get-pool>
</certificate>
</packet>


And get XML response:
<packet version="1.6.7.0">
<certificate>
<get-pool>
<result>

<status>ok</status>
<filter-id>
your-domain-name.com</filter-id>
<id>your-cert-id-number</id>

<certificates/>
</result>
</get-pool>
</certificate
</packet>


But I need retrieve additional attributes - start date, expiry date and others.

Can I do this through Plesk API?
 
You can grab it with PHP;

Code:
<?
    $url = "https://www.google.com";
    $orignal_parse = parse_url($url, PHP_URL_HOST);
    $get = stream_context_create(array("ssl" => array("capture_peer_cert" => 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);
    echo '</pre>';
?>
 
Back
Top