php-openssl - php从csr获取subjectAltName
问题描述
晚上好,我的朋友,我使用 php 通过 openssl 函数生成了 san csr。但我无法获得 subjectAltName。请问如何从csr中提取subjetAltName?
shell_exec('openssl req -noout -text -in'. $csr)
解决方案
我希望这有帮助:
$r = shell_exec('openssl req -noout -text -in '. $csr)
^- a space here!
但是对于我的测试,openssl 没有打印主题替代名称,所以我将展示如何获取主题:
preg_match('/Subject:\s*(.*)\n/', $r, $matches);
$subject = $matches[1];
推荐阅读
- javascript - 如何通过 instafeed.js 插件在我们的网站中显示 instagram 的标题部分
- arrays - 从 pyspark 数据框列创建结构数组
- javascript - 无法使用 http 删除/放置请求删除或编辑项目
- java - 有没有办法根据日志的内容更改日志的级别?
- windows - 无法使用 VSCode/GoLand 在 Windows 上调试 Go 代码(获取“%1 不是有效的 Win32 应用程序”)
- c# - 格式化小数以删除尾随零并使用千分位分隔符
- java - 运行自动化脚本时登录会话过期
- sql - 使用 Simba ODBC 驱动程序将记录从 SQL 服务器插入 Google Bigquery
- css - 在 iOS 15 Safari 上动态设置指针事件是不可靠且不可预测的
- python - 身份验证出错时,烧瓶邮件引发异常