• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

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