Java上的服务器名称指示(SNI) [英] Server Name Indication (SNI) on Java

查看:212
本文介绍了Java上的服务器名称指示(SNI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我开始使用Java中的服务器名称指示进行HTTP连接吗?

Can anyone help me get started on carrying out HTTP connections with server name indication in Java?

我正在尝试从我管理的网站请求内容。我一直在使用Apache的HttpClient库,但我对安全内容的请求失败,因为网站仅使用SNI进行HTTPS,并且在DefaultHttpClient中未启用SNI。我已经在Apache的HttpClient库中查找了如何处理这个问题的说明,但最终我看到了这个文档: http://hc.apache.org/httpclient-3.x/sslguide.html ,这已经过时了(当HttpClient和HttpCore是Apache的commons包的一部分时,请参考代码)。

I'm trying to request content from a site I'm adminstering. I've been using Apache's HttpClient library, but my request for secure content fails because the website only uses SNI for HTTPS, and SNI isn't enabled in the DefaultHttpClient. I've looked for instruction on how to approach this within Apache's HttpClient library, but I see end up with this document: http://hc.apache.org/httpclient-3.x/sslguide.html, which is out of date (referring to code back when HttpClient and HttpCore were part of Apache's commons package).

那么......任何帮助?

So... any help?

推荐答案

你可能想跟踪 https://issues.apache.org/jira/browse/HTTPCLIENT-1119

Java 7的底层客户端实现能够支持它并通过SSLSocketImpl #setHost(由sun.net.www.protocol调用)公开该功能。 Java 7使用的https.HttpsClient

the underlying client implementation of Java 7 is capable to support it and exposes the feature via SSLSocketImpl#setHost (called by sun.net.www.protocol.https.HttpsClient

    new URL("https://cmbntr.sni.velox.ch/").openStream()

直到HTTPCLIENT- 1119是固定的

until HTTPCLIENT-1119 is fixed

这篇关于Java上的服务器名称指示(SNI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆