From c228cc002b69644ed6871b4c3d8ecf50b19330c7 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 1 Oct 2024 17:56:59 -0500 Subject: [PATCH] X509: add getRequestedCertificateExtensions() --- phpseclib/File/X509.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 9c870169..2a9ac05e 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -3501,6 +3501,28 @@ class X509 return false; } + /** + * Get all requested CSR extensions + * + * Returns the list of extensions if there are any and false if not + * + * @param array $csr optional + * @return mixed + */ + public function getRequestedCertificateExtensions(array $csr = null) + { + if (empty($csr)) { + $csr = $this->currentCert; + } + + $requestedExtensions = $this->getAttribute('pkcs-9-at-extensionRequest'); + if ($requestedExtensions === false) { + return false; + } + + return $this->getAttribute('pkcs-9-at-extensionRequest')[0]; + } + /** * Returns a list of all CSR attributes in use *