Php从csr获取subjectAltName

问题描述 投票:1回答:1

晚安,我的朋友我使用php通过openssl函数生成了san csr。但是我无法获得subjectAltName。请问如何从csr提取subjetAltName?

shell_exec('openssl req -noout -text -in'. $csr)
php-openssl subject-alternative-name
1个回答
0
投票

我希望这会有所帮助:

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

但是,对于我的测试,openssl并未打印主题替代名称,所以我将展示如何获取主题:

preg_match('/Subject:\s*(.*)\n/', $r, $matches);
$subject = $matches[1];
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.