使用带有证书CN检查的双向SSL设置Apache转发代理失败

我需要build立一个双向SSLvalidation的转发代理。 我在Debian上使用的是Apache 2.4.10,但是因为证书CN与错误的名字比较,所以失败了。 我已经search和阅读每一页,远程提到类似的东西,但我找不到解决scheme。

build立:

  • 使用基于名称的虚拟主机在http:// localhost:8080上运行的tomcat服务器
  • 当触发每个虚拟主机发送一个请求到https://externalserver.com:443/uri
  • SSL连接应提供属于虚拟主机的证书并validation外部服务器的证书

我已经在Apache 2.4.10中为每个tomcat虚拟主机设置了一个虚拟主机,具有以下configuration:

 <虚拟主机*:80>
   ServerName domain1.example.com

    SSLProxyEngine开启
    ProxyVia On

    SSLProxyMachineCertificateFile /proxysetup/certs/domain1.example.certandkey.pem

    #服务器证书validation

    SSLProxyCACertificatePath / proxysetup / ca
    SSLProxyCARevocationCheck叶
    SSLProxyCARevocationPath / proxysetup / crl
    SSLProxyVerify需要
    SSLProxyVerifyDepth 4
    SSLProxyCheckPeerNameclosures
    SSLProxyCheckPeerCN上
    SSLProxyCheckPeerExpire打开

   ProxyPass /外部https://externalserver.com/ 
   ProxyPassReverse / external https://externalserver.com/

     <代理“*”>
        命令否认,允许
        全部允许
     </代理>

    LogLeveldebugging

    ErrorLog /proxysetup/logs/domain1.example-error-80.log
    CustomLog /proxysetup/logs/domain1.example-access-80.log合并

 </虚拟主机>

当我开始一个请求( http://domain1.example.com/external/someuri )我看到SSL握手发生,但失败,出现以下错误

SSL Proxy: Peer certificate CN mismatch: Certificate CN: EXTERNALSERVER.COM Requested hostname: domain1.example.com

连接然后closures。

即使在执行此检查之前,添加ProxyPerserveHost off握手停止。

需要做什么才能成功validation证书?

UPDATE

我设法通过将configuration更改为:

 <虚拟主机*:80>
   ServerName domain1.example.com

    SSLProxyEngine开启

    SSLProxyMachineCertificateFile /proxysetup/certs/domain1.example.certandkey.pem

    #服务器证书validation

    SSLProxyCACertificatePath / proxysetup / ca
    SSLProxyCARevocationCheck叶
    SSLProxyCARevocationPath / proxysetup / crl
    SSLProxyVerify需要
    SSLProxyVerifyDepth 4
    SSLProxyCheckPeerNameclosures
    SSLProxyCheckPeerCNclosures
    SSLProxyCheckPeerExpire打开

   ProxyPass / external / https://externalserver.com/ 
   ProxyPassReverse / external / https://externalserver.com/

   ProxyPass / http:// localhost:8080 /
   ProxyPassReverse / http:// localhost:8080 /

     <代理“*”>
        要求所有授予
     </代理>

   <代理“* /外部/”>
   #只允许本地请求 
   #并且只有当服务器证书包含正确的FQDN时

  要求全部否认
  要求本地
   {“externalserver.com”}中的SSLRequire%{SSL_SERVER_S_DN_CN}
   </代理>

    LogLeveldebugging

    ErrorLog /proxysetup/logs/domain1.example-error-80.log
    CustomLog /proxysetup/logs/domain1.example-access-80.log合并

 </虚拟主机>

更新2

还有一些错误:

  1. 当我改变
  {“externalserver.com”}中的SSLRequire%{SSL_SERVER_S_DN_CN}

  {“somethingelse.com”}中的SSLRequire%{SSL_SERVER_S_DN_CN}

我仍然得到一个连接。 即使在添加SSLOptions +StrictRequireSSLOptions +StrictRequire

  1. 当我设置SSLProxyCheckPeerName on

服务器的证书(externalserver.com)与domain1.example.com匹配。 我期望它匹配到'externalserver.com'

我做错了什么,或者我偶然发现了一个错误?