- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 Apache HttpClient 4.3 与 hubic.com 的 API 交互。我的最小可重现示例只是一个衬垫:
HttpClientBuilder.create().build().execute(new HttpGet("https://hubic.com"));
然而抛出:
Exception in thread "main" javax.net.ssl.SSLException: Received fatal alert: protocol_version
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1991)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1104)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1343)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1371)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:254)
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:117)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
这是我使用 System.setProperty("javax.net.debug", "all");
运行时的输出:
trustStore is: /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
trustStore type is : jks
trustStore provider is :
init truststore
adding as trusted cert: [... extremely large list ...]
trigger seeding of SecureRandom
done seeding SecureRandom
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 for SSLv3
Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 for SSLv3
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256 for SSLv3
Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 for SSLv3
Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 for SSLv3
Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 for SSLv3
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 for SSLv3
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 for TLSv1.1
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 for TLSv1.1
%% No cached client session
*** ClientHello, TLSv1.2
RandomCookie: GMT: 1402182685 bytes = { 227, 155, 148, 161, 7, 104, 221, 182, 254, 133, 216, 198, 118, 211, 223, 229, 43, 82, 207, 1, 102, 245, 112, 117, 253, 69, 43, 162 }
Session ID: {}
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_MD5, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Compression Methods: { 0 }
Extension elliptic_curves, curve names: {secp256r1, sect163k1, sect163r2, secp192r1, secp224r1, sect233k1, sect233r1, sect283k1, sect283r1, secp384r1, sect409k1, sect409r1, secp521r1, sect571k1, sect571r1, secp160k1, secp160r1, secp160r2, sect163r1, secp192k1, sect193r1, sect193r2, secp224k1, sect239k1, secp256k1}
Extension ec_point_formats, formats: [uncompressed]
Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA224withECDSA, SHA224withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA, MD5withRSA
Extension server_name, server_name: [type=host_name (0), value=hubic.com]
***
[write] MD5 and SHA1 hashes: len = 225
0000: 01 00 00 DD 03 03 54 94 9C 1D E3 9B 94 A1 07 68 ......T........h
0010: DD B6 FE 85 D8 C6 76 D3 DF E5 2B 52 CF 01 66 F5 ......v...+R..f.
0020: 70 75 FD 45 2B A2 00 00 46 C0 23 C0 27 00 3C C0 pu.E+...F.#.'.<.
0030: 25 C0 29 00 67 00 40 C0 09 C0 13 00 2F C0 04 C0 %.).g.@...../...
0040: 0E 00 33 00 32 C0 2B C0 2F 00 9C C0 2D C0 31 00 ..3.2.+./...-.1.
0050: 9E 00 A2 C0 08 C0 12 00 0A C0 03 C0 0D 00 16 00 ................
0060: 13 C0 07 C0 11 00 05 C0 02 C0 0C 00 04 00 FF 01 ................
0070: 00 00 6E 00 0A 00 34 00 32 00 17 00 01 00 03 00 ..n...4.2.......
0080: 13 00 15 00 06 00 07 00 09 00 0A 00 18 00 0B 00 ................
0090: 0C 00 19 00 0D 00 0E 00 0F 00 10 00 11 00 02 00 ................
00A0: 12 00 04 00 05 00 14 00 08 00 16 00 0B 00 02 01 ................
00B0: 00 00 0D 00 1A 00 18 06 03 06 01 05 03 05 01 04 ................
00C0: 03 04 01 03 03 03 01 02 03 02 01 02 02 01 01 00 ................
00D0: 00 00 0E 00 0C 00 00 09 68 75 62 69 63 2E 63 6F ........hubic.co
00E0: 6D m
main, WRITE: TLSv1.2 Handshake, length = 225
[Raw write]: length = 230
0000: 16 03 03 00 E1 01 00 00 DD 03 03 54 94 9C 1D E3 ...........T....
0010: 9B 94 A1 07 68 DD B6 FE 85 D8 C6 76 D3 DF E5 2B ....h......v...+
0020: 52 CF 01 66 F5 70 75 FD 45 2B A2 00 00 46 C0 23 R..f.pu.E+...F.#
0030: C0 27 00 3C C0 25 C0 29 00 67 00 40 C0 09 C0 13 .'.<.%.).g.@....
0040: 00 2F C0 04 C0 0E 00 33 00 32 C0 2B C0 2F 00 9C ./.....3.2.+./..
0050: C0 2D C0 31 00 9E 00 A2 C0 08 C0 12 00 0A C0 03 .-.1............
0060: C0 0D 00 16 00 13 C0 07 C0 11 00 05 C0 02 C0 0C ................
0070: 00 04 00 FF 01 00 00 6E 00 0A 00 34 00 32 00 17 .......n...4.2..
0080: 00 01 00 03 00 13 00 15 00 06 00 07 00 09 00 0A ................
0090: 00 18 00 0B 00 0C 00 19 00 0D 00 0E 00 0F 00 10 ................
00A0: 00 11 00 02 00 12 00 04 00 05 00 14 00 08 00 16 ................
00B0: 00 0B 00 02 01 00 00 0D 00 1A 00 18 06 03 06 01 ................
00C0: 05 03 05 01 04 03 04 01 03 03 03 01 02 03 02 01 ................
00D0: 02 02 01 01 00 00 00 0E 00 0C 00 00 09 68 75 62 .............hub
00E0: 69 63 2E 63 6F 6D ic.com
[Raw read]: length = 5
0000: 15 03 00 00 02 .....
[Raw read]: length = 2
0000: 02 46 .F
main, READ: SSLv3 Alert, length = 2
main, RECV TLSv1.2 ALERT: fatal, protocol_version
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLException: Received fatal alert: protocol_version
如果我尝试访问例如https://google.com .所以它猜测 SSL with Java 在我的系统上不能完全破坏,但它与 hubic.com 的结合有关。
错误protocol_version
不是很有帮助,但在this question建议我的客户端使用与服务器不同的协议(protocol)版本(我猜“服务器和客户端无法就协议(protocol)达成一致”会更准确)。
我如何确定服务器将同意哪些协议(protocol)版本以及如何在我的客户端中启用这些协议(protocol)版本?我是否应该担心这个问题(例如 hubic 是否只允许旧的不受支持的协议(protocol)?(Firefox 当然不会提示任何不安全的事情)。
最佳答案
我从调试中看到 Java 执行 TLS1.2 握手而不是更常见的 SSLv23 握手:
main, WRITE: TLSv1.2 Handshake, length = 225
[Raw write]: length = 230
0000: 16 03 03 00
^^^^^ - TLS1.2 (SSL3.3)
服务器本身只能执行 TLS1.0 并且不能只宣布这个旧版本。 我不熟悉 Java,但您需要将协议(protocol)版本设置为 TLSv1 或 SSLv23 才能与此服务器通信。
以下代码将仅使用 Apache HttpClient 设置 TLSv1:
HttpClientBuilder
.create()
.setSslcontext(SSLContexts.custom().useProtocol("TLSv1").build())
.build()
.execute(new HttpGet("https://hubic.com"));
编辑以包括评论中的问题:
If you say that the server "fails to just announce this older version", does that mean that the server is misconfigured? In this case, why don't Firefox&Chromium have any problems?
如果客户端在 ClientHello 中宣布 TLS1.2 而服务器只能做 TLS1.0,它应该宣布这一点,即用 TLS1.0 回复。如果 TLS1.0 不够好或继续使用 TLS1.0,则客户端可以关闭连接。但是,在这种情况下,服务器只是告诉客户端它不喜欢这个版本并关闭了连接。 Firefox 和其他公司发布了 SSLv23 公告,他们在其中进行了 TLS1.0 握手,但也公布了他们支持的最佳协议(protocol)版本。这通常适用于从 SSL3.0 开始的旧服务器,但也适用于较新的服务器。
您可以使用最近的 Perl/IO::Socket::SSL 和 this script 检查服务器的行为.
$ perl analyze-ssl.pl hubic.com
-- hubic.com port 443
* maximum SSL version : TLSv1 (SSLv23)
* supported SSL versions with handshake used and preferred cipher(s):
* handshake protocols ciphers
* SSLv23 TLSv1 AES256-SHA
* TLSv1_2 FAILED: SSL connect attempt failed error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
* TLSv1_1 FAILED: SSL connect attempt failed error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
* TLSv1 TLSv1 AES256-SHA
* SSLv3 FAILED: SSL connect attempt failed because of handshake problems error:1409442E:SSL routines:SSL3_READ_BYTES:tlsv1 alert protocol version
在这里您可以看到,主机支持 SSLv23 和 TLSv1 握手,但不支持使用的 TLSv1_2 握手。
关于java - 如何在 java 中设置 SSL 协议(protocol)版本?我怎么知道是哪一个? javax.net.ssl.SSLException : Received fatal alert: protocol_version 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27573192/
我可以看到有状态的协议(protocol)可以减少像 cookie 这样的“模拟状态”。 但是测试变得更加难以确保您的实现正确并重新连接,并且 session 继续可能很难处理。 始终使用无状态协议(
我正在尝试为我的下一个分布式应用程序找到合适的协议(protocol)中间件。在过去的几天里,我找到了几个规范,想知道我是否错过了一个重要的规范?它应该是二进制协议(protocol),支持 RPC,
我正在做一个研究生院软件工程项目,我正在寻找管理 ATM 和银行网络之间通信的协议(protocol)。 我已经在谷歌上搜索了很长一段时间,虽然我找到了各种有关 ATM 的有趣信息,但我惊讶地发现似乎
我正在开发一个 ECG 模块,它以字节为单位给出数据。有一个关于它的协议(protocol)文档解释了如何构建从模块中出来的数据包。我想解码该数据。我很困惑 Protocol Buffer 是否会对此
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 3年前关闭。 Improve this qu
我需要在我的程序中包含基本的文件发送和文件接收例程,并且需要通过 ZMODEM 协议(protocol)。问题是我无法理解规范。 供引用,here is the specification . 规范没
我最近听到这个术语来描述 Google 的新环聊协议(protocol)和 Whisper System 的新 encrypted texting app . The new TextSecure p
如何检查某个对象是否符合协议(protocol)? 我试过这种方式,但出现错误: if lCell.conformsToProtocol(ContentProtocol) { } 最佳
在应用程序中,我们有两种类型的贴纸,字符串和位图。每个贴纸包都可以包含两种类型。这就是我声明模型的方式: // Mark: - Models protocol Sticker: Codable { }
这个问题在这里已经有了答案: Why can't a get-only property requirement in a protocol be satisfied by a property w
我有以下快速代码: protocol Animal { var name: String { get } } struct Bird: Animal { var name: String
我在遵循继承树的几个类中分配协议(protocol)。像这样: 头等舱 @protocol LevelOne - (void) functionA @end @interface BaseClass
我们之前使用的是 fix,但客户说使用 OUCH 进行交易,因为这样速度更快。我在互联网上查了一下,消息看起来很相似。它如何获得速度优势。请给我一些示例消息 最佳答案 基本上,FIX 消息以文本格式传
在我的 swift 项目中,我有一个使用协议(protocol)继承的案例,如下所示 protocol A : class{ } protocol B : A{ } 接下来我要实现的目标是声明另一个具
我想根据这两种协议(protocol)的一般特征(例如开销(数据包)、安全性、信息建模和可靠性)来比较 OPC UA 和 MQTT。我在哪里可以找到每个协议(protocol)的开销和其他特性的一些示
本质上,我的最终目标是拥有一个协议(protocol) Log,它强制所有符合它的对象都有一个符合另一个协议(protocol) [LogEvent] 的对象数组. 但是,符合Log的类需要有特定类型
我正在尝试为基于左操作数和右操作数标识的协议(protocol)实现 Equatable 协议(protocol)。换句话说:我如何为一个协议(protocol)实现 Equatable 协议(pro
问题不在于编程。 我正在使用一台旧机器,微软停止了这些机器的补丁。 有没有人针对攻击者已知的使用端口 445 的 SMB 协议(protocol)漏洞的解决方案? 任何棘手的解决方案? 换句话说,我想
在我们的业务中,我们需要记录到达我们服务器的每个请求/响应。 目前,我们使用 xml 作为标准实现。 如果我们需要调试/跟踪某些错误,则使用日志文件。 如果我们切换到 Protocol Buffer
你推荐什么协议(protocol)定义? 我评估了 Google 的 Protocol Buffer ,但它不允许我控制正在构建的数据包中字段的位置。我认为 Thrift 也是如此。我的要求是: 指定
我是一名优秀的程序员,十分优秀!