【发布时间】:2012-06-06 02:00:41
【问题描述】:
上下文
我需要在 Windows Server 2008 的 IIS 7.5(http 端口 80,https 443)后面放置一个 Java 应用服务器(http 端口 8080,https 8181)。
步骤
我使用IIS ARR 模块启用代理,以便将一些请求路由到Java 应用程序服务器。为此,我还创建了一些URL Rewrite 规则。使用http,一切正常。
使用的规则规定,当请求的 URL 与模式 (MyAppContextRoot.+) 匹配时,要采取的操作是 Rewrite: http://localhost:8080/{R:0}。
对于另一个使用 https 的应用程序,重写规则为:https://localhost:8181/{R:0}。
为了路由 https 请求,我在某处读到我需要在 IIS 和 Java 之间共享相同的证书,因为 IIS 加密/解密请求/答案。如果我错了,请纠正我。
由于我仍处于开发阶段,我决定共享一个自签名证书。我已经用SelfSSL7 创建了它,我已经使用keytool 导入了java keystore:
selfSSL7 /Q /T /I "Default web site" /N cn=myDomain.com /X /F MyCertificate.pfx /W myPassword
keytool -importkeystore -srckeystore C:\myPath\MyCertificate.pfx -srcstoretype pkcs12 -srcalias my -deststoretype jks -deststorepass myPassword -destalias MyAlias
问题
两个证书都各司其职:https://myDomain.com 和 https://myDomain.com:8181 已启动并正在运行,但在尝试路由时,出现错误:
502 - Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
但是,查看证书,在以下方面存在差异:颁发者、颁发者、有效性、签名算法、密钥大小。特别是SelfSSL7创建的算法是sha1RSA(1024 Bits key),keytool创建的算法是sha256RSA(2048 Bits key)。
【问题讨论】:
-
keytool -importkeystore只会复制证书(和私钥)。如果您作为客户端连接时证书详细信息不同,则您可能尚未使用您认为的证书配置您的服务器。
标签: java encryption ssl certificate pfx