我有我的应用程序运行在负载均衡器后面的EC2上。 已获得www.example.com和* .example.com的https证书。https子证书问题
应用程序正在http上运行,但https已在负载平衡器中设置。
我在公司的应用程序中添加了子域支持。
赞,公司XYZ的https://XYZ.example.com。
如果我访问使用,https://XYZ.example.com,它的工作正常。
如果我访问使用,https://www.XYZ.example.com,浏览器的警告一样,
“www.arun.contactcentral.io的所有者已经正确配置他们的网站。为了保护您的信息不被窃取,火狐并没有连接到该网站。”
但是,如果我访问https://www.example.com,它工作正常。
虽然,我已获得* .example.com的认证,但即使访问www.XYZ.example.com也不起作用。
我有一个过滤器来处理HTTP到https的方向,但它仍然没有过滤WWW的URL。
public class HttpsFilter implements Filter {
private static final String HTTP = "http";
private static final String HTTPS = "https";
private static final String X_FORWARDED_PROTO = "X-Forwarded-Proto";
@Override
public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse httpResponse = (HttpServletResponse) res;
String xfp = request.getHeader(X_FORWARDED_PROTO);
if (HTTPS.equals(xfp)) {
//httpResponse.setHeader("Strict-Transport-Security", "max-age=60");
chain.doFilter(req, res);
return;
}
else if (HTTP.equals(xfp)) {
String serverUrl = HTTPS+"://"+req.getServerName()+((HttpServletRequest)req).getServletPath();
httpResponse.sendRedirect(serverUrl);
return;
}
}
}
感谢, Baskar.S
我可以有2个证书。但是,不允许使用www。*。example.com。我怎样才能做到这一点?我的子域名基于公司。 – user1578872
你不能。它没有被任何公认的标准支持。如果您想在前面放置“www”,每个匹配*的子域名将需要自己的证书。 –
(您可以在同一个证书中拥有多个子域,但需要明确命名,不能动态完成。) –