• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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