diff options
author | jim-p <jimp@pfsense.org> | 2011-07-06 14:32:30 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2011-07-06 14:32:30 -0400 |
commit | b34b2b7da2b525389e9d42a7474d892fd77565fa (patch) | |
tree | 13ff9b8775fee8828badd4974301b69ea4abb4f0 /etc | |
parent | 152f57596ba1984bc3ce6c603093f4573fed30df (diff) | |
download | pfsense-b34b2b7da2b525389e9d42a7474d892fd77565fa.zip pfsense-b34b2b7da2b525389e9d42a7474d892fd77565fa.tar.gz |
Add function to return a certificate's common name.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/certs.inc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/etc/inc/certs.inc b/etc/inc/certs.inc index 3f655b1..60ce951 100644 --- a/etc/inc/certs.inc +++ b/etc/inc/certs.inc @@ -649,4 +649,25 @@ function is_crl_internal($crl) { return (!(!empty($crl['text']) && empty($crl['cert'])) || ($crl["method"] == "internal")); } +function cert_get_cn($crt, $isref = false) { + /* If this is a certref, not an actual cert, look up the cert first */ + if ($isref) { + $cert = lookup_cert($crt); + /* If it's not a valid cert, bail. */ + if (!(is_array($cert) && !empty($cert['crt']))) + return ""; + $cert = $cert['crt']; + } else { + $cert = $crt; + } + $sub = cert_get_subject_array($cert); + if (is_array($sub)) { + foreach ($sub as $s) { + if (strtoupper($s['a']) == "CN") + return $s['v']; + } + } + return ""; +} + ?> |