Php get subjectAltName from csr

261 Views Asked by At

Good evening my friend I generated san csr via openssl function using php. But i cant get subjectAltName. Please How can i extract subjetAltName from csr?

shell_exec('openssl req -noout -text -in'. $csr)
1

There are 1 best solutions below

0
On

I hope this helps:

$r = shell_exec('openssl req -noout -text -in '. $csr)
                                             ^- a space here!

for my test however openssl did not print a Subject Alt Name, so i'll show how to get the Subject:

preg_match('/Subject:\s*(.*)\n/', $r, $matches);
$subject = $matches[1];