php - PHP 证书。两种方式的身份验证 ssl。 Apache

标签 php apache authentication ssl certificate

上下文:安装了 SSL 的生产服务器。运行 Apache 服务器。 PHP.

问题:对于特定的 url,例如(例如:www.domain.com/whatever/edit/*),我想要求用户使用他们的证书来验证他们的特定任务。

我读到这种身份验证方式称为双向身份验证 SSL。不知道我说的对不对。

我试过的服务器配置如下

<VirtualHost _default_:433>

ServerAdmin webmaster@localhost

DocumentRoot /Applications/MAMP/htdocs/smartdataprotection/web/

        Options FollowSymLinks

        Options Indexes FollowSymLinks MultiViews


LogLevel warn
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/ssl_access.log combined


SSLEngine on
SSLCertificateFile    /Applications/MAMP/htdocs/certificates/server.cer
SSLCertificateKeyFile /Applications/MAMP/htdocs/certificates/server.key
SSLOptions +StdEnvVars 

# Below for 2 way ssl
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile /Applications/MAMP/htdocs/certificates/ca.cer

我想得到的是类似于以下屏幕截图的内容: enter image description here

非常感谢您提供任何帮助,我们将非常欢迎并非常感谢。

问候。

最佳答案

我认为你错过了 SSLCipherSuite directive .在 apache 文档中:

This complex directive uses a colon-separated cipher-spec string consisting of OpenSSL cipher specifications to configure the Cipher Suite the client is permitted to negotiate in the SSL handshake phase.

另外,通常您希望在特定位置使用证书登录站点,而不是直接在 www.yourdomain.com 中,例如在带有转到 wwww.yourdomain.com/yourApp/loginCert 的按钮链接中所以你必须配置 <Location><VirtualHost>里面.

最后检查 SSLCACertificateFile directive中指示的文件,此文件是 PEM 中 CA 证书的串联格式,它颁发允许登录您的站点的证书,如果您的证书不是由此文件中的 CA 之一颁发的,它们将不会显示在浏览器弹出窗口中。

配置可能如下所示:

<VirtualHost _default_:433>
...
  <Location /yourApp/loginCert>

    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCACertificateFile conf/trustedCA.cer
    SSLVerifyClient required
    SSLVerifyDepth 10
    SSLOptions +StdEnvVars +ExportCertData +OptRenegotiate

  </Location>   

希望对您有所帮助,

关于php - PHP 证书。两种方式的身份验证 ssl。 Apache ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28285046/

相关文章:

javascript - php 中出现未定义索引错误

php - 从 url 自动 zip 下载

php - 在发生 fatal error 后重新创建 Git Ref

php - Dropbox 样式 URL,不使用哈希或参数

PHP如何执行命令

php - Laravel 复杂的内部加入多对多关系

php和apache线程安全错误

javascript - Python/请求 : Log In to Website Javascript

php - CakePHP Auth 检索额外数据

android - 如何在 android firebase 中保持登录状态和注销状态?