PHP 和 X.509 身份验证 - 检查证书颁发者
我试图在我的网站上设置一个特定页面,只有经过 X.509 身份验证的人才能访问。问题是,我希望所有拥有特定中间 CA 颁发的匹配证书的客户端都可以使用它(我打算在自行生成的根 CA 下拥有一些中间 CA,但只有一个由一个特定中间 CA 颁发的客户端证书可以访问此页面)。使用 PHP 可以吗?
如果我需要进一步详细说明,请告诉我,我会尝试添加更多详细信息。感谢您的帮助!
TC
I'm trying to have a specific page on my site only accessible to people after X.509 authentication. Catch is, I want it to be available to all clients who have a matching certificate issued by a specific Intermediate CA (I intend to have a few Intermediate CAs underneath a self-generated Root CA, but only a client certificate issued by one specific Intermediate CA can access this page). Is this possible using PHP?
Let me know if I need to elaborate further, and I'll try and add more detail. Thanks for your help!
TC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。当您使用 SSL 扩展和 openssl_x509_parse 函数获取证书信息时,您将可以访问证书中的所有信息。您应该能够在 php 脚本中执行此操作:
您应该在该数组中看到一个“颁发者”密钥,其中包含一个包含有关客户端证书颁发者信息的数组,我假设它可以为您提供所需的信息。
Yes. When you get the cert information using the SSL extension and the openssl_x509_parse function, you'll get access to all the information in the cert. You should be able to do this in your php script:
You should see in that array that there's an 'issuer' key with an array containing information about the client cert issuer, and I'm going to assume that gets you the information you need.
如果您不想使用 OpenSSL,您可以使用 phpseclib 的最新 SVN,一个纯 PHP X.509 解析器。例如。
if you didn't want to use OpenSSL you could use the latest SVN of phpseclib, a pure PHP X.509 parser. eg.