function saml_sp_get_cert_info in SAML Service Provider 7.2
Same name and namespace in other branches
- 7.3 saml_sp.admin.inc \saml_sp_get_cert_info()
with the certificate location retrieve pertinant certificate data and output in a string for display
1 call to saml_sp_get_cert_info()
- saml_sp__admin_config in ./
saml_sp.admin.inc - configure this SAML Service Provider
File
- ./
saml_sp.admin.inc, line 582 - Admin pages for the SAML Service Provider module.
Code
function saml_sp_get_cert_info($cert_location) {
if (!empty($cert_location) && file_exists($cert_location) && function_exists('openssl_x509_parse')) {
$encoded_cert = trim(file_get_contents($cert_location));
$cert = openssl_x509_parse(OneLogin_Saml2_Utils::formatCert($encoded_cert));
// flatten the issuer array
if (!empty($cert['issuer'])) {
foreach ($cert['issuer'] as $key => &$value) {
if (is_array($value)) {
$value = implode("/", $value);
}
}
}
if ($cert) {
$info = t('Name: %cert-name<br/>Issued by: %issuer<br/>Valid: %valid-from - %valid-to', array(
'%cert-name' => isset($cert['name']) ? $cert['name'] : '',
'%issuer' => isset($cert['issuer']) && is_array($cert['issuer']) ? implode('/', $cert['issuer']) : '',
'%valid-from' => isset($cert['validFrom_time_t']) ? date('c', $cert['validFrom_time_t']) : '',
'%valid-to' => isset($cert['validTo_time_t']) ? date('c', $cert['validTo_time_t']) : '',
));
return $info;
}
}
return FALSE;
}