• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

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